- #1
mrcleanhands
I'm trying to understand a function which draws a koch curve using a library which draws (lt = left turn, fd = move forward, t represents an object class).
So let's say I start with n = 60, then m=20 and it executes koch(t, 20), but it will never get below koch(t,m) as if the number is above 3 then it keep returning to execute itself again. This is the way I see the code:
I'm confused what happens at this point. Does it continue executing the code right until the last line and then executes each koch(t,m) call separately?
Code:
def koch(t, n):
if n<3:
fd(t, n)
return
m = n/3.0
koch(t, m)
lt(t, 60)
koch(t, m)
rt(t, 120)
koch(t, m)
lt(t, 60)
koch(t, m)
So let's say I start with n = 60, then m=20 and it executes koch(t, 20), but it will never get below koch(t,m) as if the number is above 3 then it keep returning to execute itself again. This is the way I see the code:
Code:
def koch(t, n):
if n<3:
fd(t, n)
return
m = n/3.0
koch(t, m)
DEAD CODE...
I'm confused what happens at this point. Does it continue executing the code right until the last line and then executes each koch(t,m) call separately?