Recursively traverse linked list -- help!

Yrjö Hatakka yhatakka at dlc.nospam.fi
Wed Feb 20 01:24:53 EST 2002


On 19 Feb 2002 18:13:29 -0800, Paul Rubin <phr-n2002a at nightsong.com> wrote:
> "Mike Carifio" <carifio.nospam at nospam.usys.com> writes:
>> 
>> def traverse(list):
>>     if list:
>>         print list[0]  # or do something here
>>         traverse(list[1:])
>>     else:
>>         print "done"
>> 
> 
> That's ok in Scheme but I don't think any current Python implementations
> handle tail recursion "correctly".

What do you mean? I tried above an it seems to work. When does it stop
working?

I used Python 2.2

yrjö



More information about the Python-list mailing list