On Mon, Feb 18, 2008 at 08:57:32PM -0800, [EMAIL PROTECTED] wrote:

Naively, a cons is a box that holds 2 values.  Naively, my lists are boxes
that holds an unlimited number of values.  In that regard, conses are
restricted special cases of lists as I've just defined it.

Scheme has this, it's called a vector, but it is a different structure.
Much of the language deals with lists.

I suggest you implement lists correctly, since if you don't you're going to
also have a hard time understanding a lot of what happens in the SICP list
manipulation stuff.  Python has tuples, and a 2-tuple is the same as a cons
cell.

Another example I just thought of for improper lists, is lambdas and
function definitions that take arbitrary number of arguments.  These are
represented in scheme with an improper list.

  (define (x a b . c) ...)

defines a procedure 'x' that takes at least 2 arguments.  The remaining
arguments will be passed in as a list through the variable 'c'.  If you
think about them as real lists (with cons cells), it kind of makes sense.
Saying
  (a b . c)

means that 'a' is the first element of the list, 'b' is the second element
of the list, and 'c' is all of the rest of the list.

Dave

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to