<?xml version="1.0" encoding="windows-1252"?>
<node id="74019" title="Re (tilly): (tye)Re: Golf: Tree searching" created="2001-04-19 22:22:37" updated="2005-07-19 14:08:39">
<type id="11">
note</type>
<author id="26179">
tilly</author>
<data>
<field name="doctext">
Very nice.  I tried several times without success to come
up with a good non-recursive solution.  The above not only
is short, but it really does the binary search, and
applying standard golfing techniques, it comes up a
winner at 55:
&lt;code&gt;
sub f{
($s,$t)=@_;$t=$$t{$$t{d}gt$s?l:r}while$t&amp;&amp;$$t{d}ne$s;$t
}
&lt;/code&gt;
(Or 57 if you add [my] to kill side effects.  Still
better than anything I thought of.)&lt;P&gt;

Note that this is much less readable than what [tye]
wrote, but every transformation is fairly mechanical
compression of the code...</field>
<field name="root_node">
73900</field>
<field name="parent_node">
73914</field>
</data>
</node>
