[kde-edu]: Recursion in KTurtle?

Matthias Messmer matthias at familie-messmer.de
Fri Oct 5 18:16:50 CEST 2007


Me again...

Be aware of infinite loops: "print poweroftwo -1" will serve you turtle 
soup ;-)

Happy looping

Matthias

Matthias Messmer wrote:
> Hi Ralf!
> 
> Ralf Gesellensetter wrote:
>> a colleague asks me if it isn't possible to use recursive procedures in 
>> kturtle - she failed implementing Koch-curves or fractals.
>>
>> Any clue?
> 
> Try this:
> 
> --8<-----------------------------------
> 
> learn poweroftwo x [
>   if x == 0 [
>    return 1
>   ]
>   else [
>    return 2 * poweroftwo x-1
>   ]
> ]
> 
> clear
> print poweroftwo 1



More information about the kde-edu mailing list