My understanding is that the if function does the first combinator for
nonzero numbers and the second combinator for zero numbers. This
doesn't seem to be working correctly though. Consider this code:
TUPLE: symtab key count weight left rite ;
: <symtab> ( key -- node )
1 0 0 0 symtab boa ;
"hello" <symtab>
: jjj ( node -- )
left>> [
"there is a left node" .
] [
"the left node is empty" . ] if ;
If you examine the node created by <symtab> you will see that the left link
is 0. If you give this node to the jjj function, however, jjj will tell you
that there is a left node. If you interactively use left>> on the node,
however, you can see that it is zero. I can force this to work by inserting
some code after the left>> in jjj: 0 = not
Another question: Does Factor optimize tail recursion even if the recursive
call is buried inside of combinators given to the if function?
Another question: Will Factor garbage-collect any nodes that no longer
referenced? If I want to delete a child node from the tree, can I just store
a 0 into the parent node's link to that child node, and this will cause the
child node's memory to be recovered?
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk