[squeak-dev] The Object>>recurse: Method
Kjell Godo
squeaklist at gmail.com
Fri May 27 17:42:10 UTC 2016
Object>>recurse: aZeroInputValuable"ThatReturnsATwoInputValuable"
^( aZeroInputValuable value
) value:( self )value:[ :anObject | anObject recurse: aZeroInputValuable ]
"Object>>recurse:
does for recursion what >>do: does for iteration
it enables any Object O to do recursion
Without writing a new recursive method in the Class of O
It does this even if the
BlockClosures in this version of Smalltalk being used
Can only do tail recursion accurately
Like in Dolphin Smalltalk 6
You call it like
( anObject recurse:[[ :anobject :recurse |
( anobject someChildren collect:[ :child |
( something something ).
( ( recurse value:( child something ) ) something )
]
) asSomeObjectSomething
]] )
ok
So i haven't actually tried it yet
so i do not actually know if it actually works
so it's too hot off the presses for that
because I'm more into a math major than physics
i guess i always like math way better
and so i have a tendency to say that has already been shown
but i can't see how it can fail
So i am putting it out there right now without testing it first
each recursion creates a new twoInputValuable
and the >>recurse: method keeps getting called
from inside of itself
so i think it works
but i guess you have to try it to find out
if you can figure an easier way
or why it can't work
then please show it
i have been trying to do this for a long time
and it shocks me that it's so small must be something wrong in there
so if you easily find a better way
or that it's no way at all
then i missed it and I'm too early
and I'm semi mal informed
ie stupeid
and I'm a baaad scientrist cepting I'm not one
et all
not quite easily done
Kjell E Godo"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160527/798609ea/attachment.htm
More information about the Squeak-dev
mailing list
|