On Sun, Mar 04, 2012 at 04:17:39PM +0100, Ralf Hemmecke wrote:
>> Example
>> -------
>>    a Tree over a type T  is either a  Leaf  or
>>    a  Node  containing  v: T,  left branch Tree,  and  right branch Tree.
>>
>
> Does this help?
>
> https://github.com/hemmecke/fricas-svn/blob/master/src/algebra/tree.spad.pamphlet#L28


I try to follow this, only to have a simpler example.
Define a  
         binary tree with INT in its nodes:

-------------------------------------------------------
INT ==> Integer

)abbrev domain BTREE BTree
BTree() : Export == Implementation  where

  Export == SetCategory  with
            tree    : INT -> %
            sumTree : %   -> INT

  Implementation == add

     Node := Record(val : INT, left : %, right : %)
     Rep  := Union(leaf : INT, node : Node)

     tree(n : INT) : % ==   [n]  :: Rep

     sumTree tr ==
             tr case leaf => tr.leaf
             tr case node =>
                          nd := tr.node
                          nd.val + sumTree(nd.left) + sumTree(nd.right)
--------------------------------------------------

   -> tree 0

   Internal Error
   The function coerce with signature hashcode is missing from domain 
      BTree 

Please, how to correct this?
How to change the implementation     tree(n)
so that it would build, for example,
 
                          n
                        /   \ 
                      n+1    n-1          
                                     :: BTree
? 

Thanks,

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