Well, "car" and "cdr" don't really fit; the key and value of a pair can be any
type of object, unlike the Lisp case where the cdr is always a list
(while the car can be either a list or an atom).  But you can always
define your own accessor methods with whatever names you like. :)

What's an associative list, how does it differ from an associative array,
and how is it wimpy?  Perl hashes *are* associative arrays; we only started
calling them "hashes" because it's shorter.  Java uses the even shorter
term "Map" (no extra syllable in the plural), while Python calls them
"dictionaries", but they're all the same thing . . .

I like .key/.value because it lets us mentally slice a hash the other way
without changing the terminology.  Normally we regard a hash as a pair
of arrays, one of which is returned by the 'keys' function and one
by the 'values' function.  Now we can instead regard it as an array of pairs
and use the singular 'key' and 'value' on each one to get the
corresponding element.  (In fact, I imagine that in Perl6 the 'each' function
will, in scalar context, return a pair object?)

On Fri, Oct 05, 2001 at 06:30:17PM -0400, Sam Tregar wrote:
> Can I get a .car and a .cdr please?  In my limited mind "key" and "value"
> are specific to hashes and their wimpy brother associative lists.
> 
> -sam
> Can I get a what what?

-- 
Mark J. REED    <[EMAIL PROTECTED]>

Reply via email to