Home

sorry i think that i express wrong. having problem with english


what i mean is how python knows to add all thing at the end of recursion

>>> def f(l):
if l == []:
return []
else:
return f(l[1:]) + l[:1]


f([1,2,3])

recursion1 f([2,3]) + [1]

recursion2 f([3]) + [2] or [2, 1]?

recursion3 f([]) + [3] or [3, 2, 1]


i dont get all this

>>> def f(l):
if l == []:
print l
return []
else:
return f(l[1:]) + l[:1]

>>> f([1,2,3])
[]
[3, 2, 1] # how this come here? how python save variables from each recursion?


sorry again for first post


thanks

previous
next

Re: Embedded Systems, please suggest microcontroller and compiler
Re: Sorting lists by struct member variables
Re: String Constant absent in C++
GUI for viewing/editing python data structures?
Adventure-Engines in Python
unibet
kabiny prysznicowe
systemy sygnalizacji pożaru
fartuchy lekarskie
LG Shine