[Sugar-devel] [IAEP] Factorisation visualisation was Sugar Digest 2013-01-25

Edward Mokurai Cherlin mokurai at sugarlabs.org
Sun Jan 27 14:04:33 EST 2013


You can't do functions with arguments in Turtle Art, and so obviously
you can't do full recursion with stacked and shadowed arguments
directly in Turtle Art, but you can implement much of recursion in any
of the usual ways using the push and pop stack blocks or other dodges.
Have a look at the fractal examples in the library. Or you could call
Python to create a list to store partial results in.

The case of tail recursion, where none of the recursive calls have to
return because the recursive call is the last statement in the
function, is easy. In pseudocode, with handwaving of some details that
I leave as exercises,

Set count to 0

Give variable n a positive integer value.

Factorize
If n=1, end
ElseIf n is prime, push n; increment count
Else find a factor m of n, and push that factor; increment count
Factorize n/m

ShowResult
while count>0
  print pop m
  decrement count

Of course in Logo you have full recursion. In the Etoys version of
Turtle Art, you can use recursion in Smalltalk.

On Sun, January 27, 2013 3:14 am, Alan Jhonn Aguiar Schwyn wrote:
>> To: sthomas1 at gosargon.com
>> From: forster at ozonline.com.au
>> Date: Sun, 27 Jan 2013 16:44:51 +1100
>> CC: iaep at lists.sugarlabs.org; sugar-devel at lists.sugarlabs.org
>> Subject: [IAEP] Factorisation visualisation was Sugar Digest 2013-01-25
>>
>> > > http://www.datapointed.net/visualizations/math/factorization/animated-diagrams/
>> >
>> >
>> > Beautiful, thanks for sharing. If anyone does code this up, please
>> allow
>> > for stepping (rather than playing) and allow kids to enter numbers and
>> > factors, so they can guess and look for patterns.  Or kids could
>> create
>> > their own versions in Turtle Art or Etoys as part of a lesson.
>>
>> Hi
>>
>> Clunky but working in Turtle Art at
>> http://wiki.sugarlabs.org/go/File:Turtle_Art_factors.ta
>>
>> Its limited to 3 factors, I couldn't see any way to have an arbitary
>> number of factors without recursion and I couldn't see any way to get
>> recursion in Turtle Art
> Good!
> I change the .ta to this "automatic version" that begins in 1 and
> continues.. see .ta attached..
>>
>> Tony

-- 
Edward Mokurai (默雷/निशब्दगर्ज/نشبدگرج) Cherlin
Silent Thunder is my name, and Children are my nation.
The Cosmos is my dwelling place, the Truth my destination.
http://wiki.sugarlabs.org/go/Replacing_Textbooks


More information about the Sugar-devel mailing list