> The code for 'node?' is contained in 'src/algebra/tree.spad.pamphlet'
>
> node?(t1, t2) ==
> t1 = t2 => true
> t case empty => false
> any?(inode?, children t2) where
> inode?(t: %): Boolean == node?(t1, t)
>
> however in addition to the nested function in also contains an
> undefined variable 't'. Presumably this should be 't2'. After applying
> your patch and the change
>
> t2 case empty => false
>
> The compiler silently *appears* to correctly compile 'node?' (no
> errors or warnings), but the function is still missing from the
> resulting domain!!
>
> Here is a version of 'node?' that avoids the the use of a local
> function. It compiles and works as expected:
>
> node?(t1:%, t2:%):Boolean ==
> t1 = t2 => true
> t2 case empty => false
> for t in children t2 repeat
> node?(t1,t) => return true
> false
>
... and is basically the same code as appears in
BinaryRecursiveAggregate in aggcat.spad.pamphlet.
if % has SetAggregate(S) and S has SetCategory then
node?(u,v) ==
empty? v => false
u = v => true
for y in children v repeat node?(u,y) => return true
false
I think, it is even easier to understand than the "any?(..)" version.
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
-~----------~----~----~----~------~----~------~--~---