From week 4 till now, the class have been focused on recursion a lot. Most of the time we have been trying to understand and be able to use recursion.
So, what is recursion?
I'll provide a example:
def re(s:lst):
for i in s
if i == []:
return True
elif i.isinstance(i,list):
re(i)
else:
pass
return False
this is a simple example of recursion. it checks if there is a empty list in the big list, and will return True if there is. if there is a list in the big list, it will rerun the function re again.
Basically recursion is calling the function inside the function.
Friday, February 28, 2014
Sunday, February 2, 2014
Week four
In this week we focused on recursive functions. we traced through a couple
recursive functions, one that found the level of nesting within a list and
another that used turtles to draw fractals。also in class we examined a program
that used turtles to draw a simple fractal pattern we referred to as a tree
burst.
Also
i want really wanna say thank you to my lab partner, he helped me with a lot of
understanding of the material.
Subscribe to:
Posts (Atom)