[Tutor] Recursion - Beginner

2010-05-28 Thread Shawn Blazer
Hello! I'm a high school student, and I'm having some trouble learning  
recursion in my class...

For example:

Trace the sequence of recursive calls that glee(2,1) spawns:

def glee ( idol , scrub ) :
if idol == 0 :
return scrub
elif idol < 0 :
return scrub + glee ( idol + 10 , idol % 3 )
else :
return scrub + glee ( idol - scrub , idol % 3 )

Also, I'm not really sure what a question like this is asking...


getLeaves ( jenny )

[5,3,0,9]


getLeaves ( joshua )

[15,17,19,11,13]

I know its really simple, but I'm really new to this and I'd really  
appreciate some help.

Thanks!

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Homework Problem

2010-05-28 Thread Shawn Blazer


This problem told me to use map and filter, so how would I use that to  
solve it?



remove ( 5 , 6 )

6

remove ( 5 , 5 )
remove ( 1 , [1 , [1 , [2 , 13]] , 1 , [2] , 5] )

[[[2 , 13]] , [2] , 5]


remove ( 2 , [1 , [1 , [2 , 13]] , 1 , [2] , 5] )

[1 , [1 , [13]] , 1 , [] , 5]

Thanks!

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor