On Tue, Apr 17, 2012 at 05:55:36PM +0200, Waldek Hebisch wrote:
[..]
> > 
> > ------------------------------------------------------------------------
> > )abbrev category UNPARSE UnparserCategory
> > UnparserCategory(T : Type) : Category == with (show : T -> String)
> > 
> > )abbrev package LUNPARS ListUnparser
> > ListUnparser(T : Type, UT : UnparserCategory(T)) : _
> >                                                UnparserCategory(List(T))
> >  == add
> >     show(xs : List T) : String ==      
> >                         empty? xs => "[]"
> >                         x   := first xs
> >                         xs  := rest  xs
> >                         str := concat("[", show(x) $UT)
> >                         while  not empty?(xs)  repeat
> >                                x   := first xs
> >                                    xs  := rest  xs
> >                                    str := concat[str, ",", show(x) $UT]
> >                                    concat(str, "]")
> 
>                                    ^^^^ Indentation error
>                           str
> > ------------------------------------------------------------------------
> > 
[..]

> (3) -> l := [[-1, 2], []]  
> 
>    (3)  [[- 1,2],[]]
>                                                     Type: List(List(Integer))
> (4) -> show(l)$ListUnparser(List INT, ListUnparser(INT, IntegerUnparser))
> 
>    (4)  "[[-1,2,[]"
>                                                                  Type: String
> 
> Of course, I defined appropriate IntegerUnparser.  And missing final
> "]" is because you forgot final assignment in the loop.
> 
> Note: you need to use 'show(l)$P' where P is appropriate package.
> I suggest to build P when you analyze type descriptor (without
> type descriptor building T would be tricky).
> 

To program forming this package P looks the same as the initial problem 
of programming `show'.
(?)
In principle, I need to try and see now whether the categories  Show and 
Parse, and the related packages made after your design, can help my 
parser  
                 parseEvaluateShow : String -> String
written in Spad.
May be, this will work, I am not sure, so far.
But I hope to convince the Spad developers to introduce `extend' -- which
will make possible a most natural general style "by domain construction'.

Regards,

------
Sergei
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to