axiom-mail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fricas-devel] Re: [Axiom-mail] Programming with BTREEs.


From: Ralf Hemmecke
Subject: Re: [fricas-devel] Re: [Axiom-mail] Programming with BTREEs.
Date: Tue, 07 Apr 2009 15:25:22 +0200
User-agent: Thunderbird 2.0.0.19 (X11/20090105)

but
[e,[5,1],[[a,[1,1],b],[1,1],[c,[1,2],address@hidden

cannot work, I think, because the argument types don't match.  You
will need to allow also binary trees.

Ooops. You are completely right.

The last part in the input file can be replaced by

----
S==>Symbol
L==>List Integer
U==>Union(BT,S)

construct(x: U, l: L, y: U): U ==
  u: BT := if x case S then binaryTree(x::N) else x::BT
  v: BT := if y case S then binaryTree(y::N) else y::BT
  binaryTree(u, l, v)::U

l: List U := [a,b,c,d,e]
(a,b,c,d,e):=(l 1, l 2, l 3, l 4, l 5)
u: U := [e,[5,1],[[a,[1,1],address@hidden,[1,1],[c,[1,2],address@hidden@U]
bt2: BT := u :: BT
----

where the @U part is necessary (though ugly) since otherwise Axiom (oh, FriCAS in my case) falsely creates

(25) -> [a,[1,2],b]

   (25)  [a,[1,2],b]
                            Type: List(Any)

which is a very unspecific (and bad) choice in the pressence of my new function from above and a and b being both variables of type U.

Yet another instance of why I hate "Any".

Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]