<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 29 May 2016 at 02:04, marcel.taeumel <span dir="ltr">&lt;<a href="mailto:Marcel.Taeumel@hpi.de" target="_blank">Marcel.Taeumel@hpi.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Kjell Godo wrote<br>
<div><div class="h5">&gt; Object&gt;&gt;recurse: aZeroInputValuable&quot;ThatReturnsATwoInputValuable&quot;<br>
&gt;<br>
&gt; ^( aZeroInputValuable value<br>
&gt;  ) value:( self )value:[ :anObject | anObject recurse: aZeroInputValuable<br>
&gt; ]<br>
&gt;<br>
&gt; &quot;Object&gt;&gt;recurse:<br>
&gt;<br>
&gt; does for recursion what &gt;&gt;do: does for iteration<br>
&gt;<br>
&gt; it enables any Object O to do recursion<br>
&gt; Without writing a new recursive method in the Class of O<br>
&gt;<br>
&gt; It does this even if the<br>
&gt; BlockClosures in this version of Smalltalk being used<br>
&gt; Can only do tail recursion accurately<br>
&gt; Like in Dolphin Smalltalk 6<br>
&gt;<br>
&gt; You call it like<br>
&gt;<br>
&gt; ( anObject recurse:[[ :anobject :recurse |<br>
&gt;        ( anobject someChildren collect:[ :child |<br>
&gt;               ( something something ).<br>
&gt;               ( ( recurse value:( child something ) ) something )<br>
&gt;               ]<br>
&gt;        ) asSomeObjectSomething<br>
&gt; ]] )<br>
&gt;<br>
&gt; ok<br>
&gt; So i haven&#39;t actually tried it yet<br>
&gt; so i do not actually know if it actually works<br>
&gt; so it&#39;s too hot off the presses for that<br>
&gt; because I&#39;m more into a math major than physics<br>
&gt; i guess i always like math way better<br>
&gt; and so i have a tendency to say      that has already been shown<br>
&gt; but i can&#39;t see how it can fail<br>
&gt; So i am putting it out there right now without testing it first<br>
&gt; each recursion creates a new twoInputValuable<br>
&gt; and the &gt;&gt;recurse: method keeps getting called<br>
&gt; from inside of itself<br>
&gt;<br>
&gt; so i think it works<br>
&gt;<br>
&gt; but i guess you have to try it to find out<br>
&gt;<br>
&gt; if you can figure an easier way<br>
&gt; or why it can&#39;t work<br>
&gt; then please show it<br>
&gt;<br>
&gt; i have been trying to do this for a long time<br>
&gt; and it shocks me that it&#39;s so small     must be something wrong in there<br>
&gt; so if you easily find a better way<br>
&gt; or that it&#39;s no way at all<br>
&gt; then i missed it and I&#39;m too early<br>
&gt; and I&#39;m semi mal informed<br>
&gt; ie stupeid<br>
&gt; and I&#39;m a baaad scientrist       cepting I&#39;m not one<br>
&gt; et all<br>
&gt; not quite easily done<br>
&gt;<br>
&gt; Kjell E Godo&quot;<br>
<br>
</div></div>Hi Kjell,<br>
<br>
I suppose that this code is a suggestion for Trunk? If you did not try it<br>
out, where does it come from? Dolphin Smalltalk 6?<br>
<br>
It does look like a valuable addition to me. Although, I read it like<br>
re-curse and thought of Monkey Island and LeChuck. :-D Are there other words<br>
for this?<br>
<br>
#combine:<br>
#doRecursive:<br>
<br>
Anyway, it seems to work for Fibonacci:<br>
<br>
6 recurse: [[:number :step |<br>
   number caseOf: {<br>
      [0] -&gt; [1].<br>
      [1] -&gt; [1].<br>
   } otherwise: [<br>
      (step value: number - 2)<br>
         + (step value: number - 1)]]].<br></blockquote><div><br></div><div>I bet you&#39;d like it a whole lot less if someone used it and you had to debug it. I&#39;ve done things that were at most half as tricky as this [1], and it was NOT fun to debug. In fact, trying to do so breaks the debugger if you do the obvious thing and try debug-edit-and-resume, and I still owe a fix for that...</div><div><br></div><div>frank</div><div><br></div><div>[1] <a href="https://github.com/frankshearar/Parsing-Derivatives/blob/master/Derivatives/DerivingParser.st#L199..L226">https://github.com/frankshearar/Parsing-Derivatives/blob/master/Derivatives/DerivingParser.st#L199..L226</a></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Best,<br>
Marcel<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://forum.world.st/The-Object-recurse-Method-tp4897901p4897988.html" rel="noreferrer" target="_blank">http://forum.world.st/The-Object-recurse-Method-tp4897901p4897988.html</a><br>
Sent from the Squeak - Dev mailing list archive at Nabble.com.<br>
<br>
</blockquote></div><br></div></div>