List Processing Capabilities
Terry Reedy
tjreedy at udel.edu
Tue Sep 12 12:45:17 EDT 2000
"Jim Sabatke" <jsabatke at execpc.com> wrote in message
news:39bcfac4$0$99040$726baab at news.execpc.com...
> Are the list processing capabilities in Python sufficiently Lisp-like to
> perform AI types of processing?
I consider Python's list processing capabilities to be superior. One thing
to watch for is that Python is more oriented toward efficiently
manipulating the tail of a list while Lisp addresses the front of a list.
So (where '+_=' means 'more or less the appropriate equivalent'):
(cons item list) +_= list.append(item)
(head list) =? (car list) +_= list[-1] (also list.pop())
(tail list) =? (cdr list) +_= list[:-1] (also a side-effect of
list.pop())
Python's direct indexing replaces cddddar-type constructions and are much
clearer.
Python's slicing would require a pair of reverses to simulate in at least
some dialects of Lisp. As others already noted, what you lose is
data/program equivalence.
Terry J. Reedy
More information about the Python-list
mailing list