As to my subjective opinion, it is considerably more complex, because it
is difficult for me to guess of adding
`node: ...', `Node == Record ...', `rep' and `per'.
I like the rep/per very much, because it clearly distinguishes between %
and Rep.
That you *need*
empty: () -> %
node: (Key, Value, %, %) -> %
is clear. In Haskell you would get the constructors for free, in SPAD
you don't, i.e. no guessing.
You could also do without the extra Node type and simply put the RHS of
Node == Record(...)
directly into the definition of Rep.
This line
n: Node := (rep t)::Node
is also not necessary, but it makes the code more readable.
But with CostructedDomain, it was more difficult
Maybe you rethink over that domain and re-program it in a similar way to
the sample code that I've shown.
The necessity of type recursion is joint there with a particular
_tagged union_ to express the domain construction.
In reality I would have made
Rep == Record(key: Key, value: Value, left: %, right: %)
and interpreted the NIL pointer as the empty tree, i.e.
empty(): % == (NIL$Lisp) pretend %
but I wanted to make the program as similar to Haskell as possible.
Ralf
--
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.