Sorry, I read your mail too late. The code you demonstrate here should
also work. What is so bad with it except tht it is a bit lengthy?
You cannot expect that code that looks elegant in one language looks
equally elegant in another one. There are probably also SPAD programs
that you cannot equally elegantly express in Haskell.
We are not starting a language war here, are we? (I don't take part in
it anyway.)
Ralf
------------------------------------------------------------------------
category Show() : Category == SetCategory with show : % -> String
--------------
domain Integer() : Export == Implementation where
-- add Show to the domain of Integer
Export == Join(Integer export, Show)
Implementation == Integer add
show n == string n
--------------
domain Product(S : SetCategory, T : SetCategory) :
Export == Implementation where
Export == Product(S,T) export
if S has Show and T has Show then Show
-- add Show to the domain of Product
Implementation == Product(S, T) add
if S has Show and T has Show then Show
-- add Show to the domain of Product
Implementation == Product(S, T) add
if S has Show and T has Show then
show(p : %) : String ==
concat[ "(", show (first p), ",", show (second p), ")" ]
--------------
domain List(T : Type) : Export == Implementation where
Export == Product export
if T has Show then Show -- add to the List(T) domain
Implementation == List(T) add
if T has Show then
show(xs : %) : 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, "]")
------------------------------------------------------------------------
--
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.