[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to remove verbosity from the data passing mechanism using alist

From: Fren Zeee
Subject: Re: How to remove verbosity from the data passing mechanism using alist or plist ?
Date: Wed, 8 Dec 2010 18:30:58 -0800

On Wed, Dec 8, 2010 at 8:39 AM, Chong Yidong <address@hidden> wrote:
> Fren Zeee <address@hidden> writes:
>> cons expects the second argument to be a list
> No it doesn't.
> Please refer to An Introduction to Programming in Emacs Lisp, Chapter 7,
> "car, cdr, cons: Fundamental Functions".
Thanks a lot !
You can now see that I have read the link and highlighting shows I have understood the point. Now, lets get moving with the rest of the ideas of Thien-Thi .
     (cons 'pine '(fir oak maple))

After evaluating this list, you will see

     (pine fir oak maple)

appear in the echo area. cons causes the creation of a new list in which the element is followed by the elements of the original list.

We often say that `cons puts a new element at the beginning of a list; it attaches or pushes elements onto the list', but this phrasing can be misleading, since cons does not change an existing list, but creates a new one.

Build a list
cons must have a list to attach to.9 You cannot start from absolutely nothing. If you are building a list, you need to provide at least an empty list at the beginning. Here is a series of cons expressions that build up a list of flowers. If you are reading this in Info in GNU Emacs, you can evaluate each of the expressions in the usual way; the value is printed in this text after ‘⇒’, which you may read as `evaluates to'.
    (cons 'buttercup ())
         ⇒ (buttercup)
    (cons 'daisy '(buttercup))
         ⇒ (daisy buttercup)
 The second example, (cons 'daisy '(buttercup)) constructs a new, two element list by putting daisy in front of buttercup;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]