On Mon, Apr 16, 2012 at 09:10:40PM +0000, Mark Clements wrote:
> A hack using packages is given below. This currently works for T in {Integer, 
> Symbol}, List(T), Product(S,T) and Product(List(S),List(T)). Extension should 
> not be too painful...
> 
> Kindly, Mark.
> 

1. But how to call _this_ `show', for example, for  
                                               List List List Integer ?
So far, I failed with   List List Integer.
Am I missing something?

2.
>       if Show has (show:T->String) ...

Did you mean   `if T has (show:T->String) ...'  ?

Regards,

------
Sergei
[email protected]




-------------------------------------------------------------------------
> -- base types
> )abbrev package SHOW Show
> Show() : Export == Implementation  where
>    Export == with
>       show: Integer -> String
>       show: Symbol -> String
>       -- etc
>    Implementation == add
>       show (n:Integer) == string n
>       show (n:Symbol) == string n
>       -- etc
> 
> -- single type (e.g. homogeneous aggregates)
> )abbrev package SHOW1 Show1
> Show1(T:SetCategory) : Export == Implementation where
>    Export == with
>       if Show has (show:T->String) then
>          show: List(T) -> String
>    Implementation == add
>       if Show has (show:T->String) then
>          show(xs : List(T)) : String ==                  -- print xs  to 
> string
>             empty? xs => "[]"
>           x   := first xs
>           xs  := rest  xs
>           str := concat("[", show x)
>           while  not empty?(xs)  repeat
>                x   := first xs
>                xs  := rest  xs
>                str := concat[str, ",", show x]
>           concat(str, "]")
> 
> -- two types
> )abbrev package SHOW2 Show2
> Show2(S:SetCategory, T:SetCategory) : Export == Implementation where
>    Export == with
>       if Show has (show:S->String) and Show has (show:T->String) then
>          show: Product(S,T) -> String
>    Implementation == add
>       if Show has (show:S->String) and Show has (show:T->String) then
>          show(p : Product(S,T)) : String ==
>           concat[ "(", show (selectfirst p), ",", show (selectsecond p), ")" ]
> 
> -- composition
> )abbrev package SHOWN Shown
> Shown(S:SetCategory, T:SetCategory) : Export == Implementation where
>    Export == with
>       if Show1(S) has (show:List(S)->String) and Show1(T) has 
> (show:List(T)->String) then
>          show: Product(List(S),List(T)) -> String
>       -- etc
>    Implementation == add
>       if Show1(S) has (show:List(S)->String) and Show1(T) has 
> (show:List(T)->String) then
>          show(p : Product(List(S),List(T))) : String ==
>           concat[ "(", show (selectfirst p), ",", show (selectsecond p), ")" ]
> 
> )if false
> show 'a
> show [1,2,3]
> show makeprod(1,'a)$Product(Integer,Symbol)
> show makeprod([1,2],[a,b])$Product(List(Integer),List(Symbol))
> )end if
> 
> -- 
> 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.
> 
>       

-- 
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