On Tue, Apr 17, 2012 at 05:55:36PM +0200, Waldek Hebisch wrote: [..] > > I am trying to understand and to simplyfy the example: > > > > ------------------------------------------------------------------------ > > )abbrev category UNPARSE UnparserCategory > > UnparserCategory(T : Type) : Category == with (show : T -> String) > > [..]
> (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. > I cannot repeat your example. And you do not show your IntegerUnparser. I repeat below the improved code. Please, what is wrong there? Thanks, ------ Sergei [email protected] ------------------------------------------------------------------------ INT ==> Integer )abbrev category UNPARSE UnparserCategory UnparserCategory(T : Type) : Category == with (show : T -> String) )abbrev package INTUNPA IntegerUnparser IntegerUnparser() : UnparserCategory(INT) == add show(n : INT) : String == convert(n) :: 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, "]") ------------------------------------------------------------------------ -> show(2)$IntegerUnparser "2" -> show([2,2])$ListUnparser(INT,IntegerUnparser) "NIL" This is FriCAS-1.1.6 + SBCL 1.0.55. -- 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.
