On Thu, Feb 21, 2008 at 12:30:08PM -0800, [EMAIL PROTECTED] wrote:
On Thu, Feb 21, 2008 at 08:53:43AM -0800, David Brown wrote:
Very different operation. Scheme's append doesn't modify the original
list. Python "list" append adds the element to the existing list. This is
more like scheme's "append!" call.
OK just so I'm clear... When you append to a Scheme's list, you are replacing
the empty list at the end with (new_element . () ). So the only part of
the initial list that get's "modified" is the pointer to that last cdr right?
No. Scheme's "append" creates an entirely new list which is a copy of its
first argument, whose cdr then points to its second argument. Actually, it
takes any number of arguments, and copies all but the last. Ever cons cell
in the non-final arguments lists is copied.
There is an "append!" which modifies the lists, but normal append does not.
David
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg