python list handling and Lisp list handling

Michele Simionato michele.simionato at gmail.com
Sat Apr 25 04:14:11 EDT 2009


On Apr 25, 10:01 am, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> Mark Tarver <dr.mtar... at ukonline.co.uk> writes:
> > "Assuming the following Python encodings, and ignoring questions
> > of performance, would Python and Lisp lists then be observationally
> > indistinguishable? i.e. would these then be fair encodings?"
> > is a 'yes'.   Any disagreement?
>
> I don't think it is equivalent:
>
>     Python 2.4.4 (#1, Oct 23 2006, 13:58:00)
>     [GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2
>     Type "help", "copyright", "credits" or "license" for more information.
>     >>> a = [1,2,3]
>     >>> b = [4,5,6]
>     >>> a[1:] = b   # the idea is to simulate (setf (cdr a) b)
>     >>> print a
>     [1, 4, 5, 6]
>     >>> b[0] = 9    # (setf (car b) 9)
>     >>> print a
>     [1, 4, 5, 6]    # would expect [1,9,5,6]

I think he meant to restrict the equivalence to
immutable conses.



More information about the Python-list mailing list