<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 29 May 2016 at 02:04, marcel.taeumel <span dir="ltr"><<a href="mailto:Marcel.Taeumel@hpi.de" target="_blank">Marcel.Taeumel@hpi.de</a>></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">> Object>>recurse: aZeroInputValuable"ThatReturnsATwoInputValuable"<br>
><br>
> ^( aZeroInputValuable value<br>
> ) value:( self )value:[ :anObject | anObject recurse: aZeroInputValuable<br>
> ]<br>
><br>
> "Object>>recurse:<br>
><br>
> does for recursion what >>do: does for iteration<br>
><br>
> it enables any Object O to do recursion<br>
> Without writing a new recursive method in the Class of O<br>
><br>
> It does this even if the<br>
> BlockClosures in this version of Smalltalk being used<br>
> Can only do tail recursion accurately<br>
> Like in Dolphin Smalltalk 6<br>
><br>
> You call it like<br>
><br>
> ( anObject recurse:[[ :anobject :recurse |<br>
> ( anobject someChildren collect:[ :child |<br>
> ( something something ).<br>
> ( ( recurse value:( child something ) ) something )<br>
> ]<br>
> ) asSomeObjectSomething<br>
> ]] )<br>
><br>
> ok<br>
> So i haven't actually tried it yet<br>
> so i do not actually know if it actually works<br>
> so it's too hot off the presses for that<br>
> because I'm more into a math major than physics<br>
> i guess i always like math way better<br>
> and so i have a tendency to say that has already been shown<br>
> but i can't see how it can fail<br>
> So i am putting it out there right now without testing it first<br>
> each recursion creates a new twoInputValuable<br>
> and the >>recurse: method keeps getting called<br>
> from inside of itself<br>
><br>
> so i think it works<br>
><br>
> but i guess you have to try it to find out<br>
><br>
> if you can figure an easier way<br>
> or why it can't work<br>
> then please show it<br>
><br>
> i have been trying to do this for a long time<br>
> and it shocks me that it's so small must be something wrong in there<br>
> so if you easily find a better way<br>
> or that it's no way at all<br>
> then i missed it and I'm too early<br>
> and I'm semi mal informed<br>
> ie stupeid<br>
> and I'm a baaad scientrist cepting I'm not one<br>
> et all<br>
> not quite easily done<br>
><br>
> Kjell E Godo"<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] -> [1].<br>
[1] -> [1].<br>
} otherwise: [<br>
(step value: number - 2)<br>
+ (step value: number - 1)]]].<br></blockquote><div><br></div><div>I bet you'd like it a whole lot less if someone used it and you had to debug it. I'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>