The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by haasm]

Hi,
you mention in 6.6 (Nested lists ...): "This is again an advanced topic ..."
Hm! I need more knowledge about nested lists but didn't find out where to
read. Is there somewhere a tutorial on this subject matter? (Normally I'm
doing my work in Lisp. It's difficult to apply Lisper habits 1:1 to Python.)

Thanks in advance

Max
import-bot (20211) [Avatar] Offline
#2
Re: Nested lists
[Originally posted by daryl harms]

> Hi,
> you mention in 6.6 (Nested lists ...): "This is again an advanced topic ..."
> Hm! I need more knowledge about nested lists but didn't find out where to
> read. Is there somewhere a tutorial on this subject matter? (Normally I'm
> doing my work in Lisp. It's difficult to apply Lisper habits 1:1 to Python.)
>
> Thanks in advance
>
> Max

Hi Max,

I'm not aware of any tutorials on the subject. Python allows you to define and
manipulate lists of any level of nesting you desire and you can trivially
create simple functions for "car" and "cdr", i.e.:

>>> f = [[1],[[[2,3]],4],5]
>>> def car(lst):
return lst[0]

>>> def cdr(lst):
return lst[1:]

>>> car(f)
[1]
>>> cdr(f)
[[[[2, 3]], 4], 5]
>>>

But the generalization to "caddr", "cddar" and such would be a different story!

I would expect you will probably get frustrated if you try to map your Lisp
habits 1:1 to Python. But such things as the intuitive understanding of
recursion that you've no doubt developed from lisp can be transfered over.

Daryl
import-bot (20211) [Avatar] Offline
#3
Re: Nested lists (Python for Lisp programmers)
[Originally posted by daryl harms]

> Hi,
> you mention in 6.6 (Nested lists ...): "This is again an advanced topic ..."
> Hm! I need more knowledge about nested lists but didn't find out where to
> read. Is there somewhere a tutorial on this subject matter? (Normally I'm
> doing my work in Lisp. It's difficult to apply Lisper habits 1:1 to Python.)
>
> Thanks in advance
>
> Max

Hi Max,

As an update, there was a pointer in the Python newsgroup this weekend to a
very well written introduction to Python for Lisp programmers written by Peter
Norvig. It can be found at:
http://www.norvig.com/python-lisp.html

I think this may be exactly what you were looking for.

Daryl