[Top][All Lists]

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

Re: Creating a list

From: David Kastrup
Subject: Re: Creating a list
Date: Thu, 19 Nov 2009 09:35:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

Cecil Westerhof <address@hidden> writes:

> At the moment I create a list with:
>       (setq ret-val (cons total-amount (cons current-amount ())))
> I thought about doing it with:
>       (setq ret-val (cons total-amount '(current-amount)))
> But then the second value is the string current-amount

Wrong.  The _symbol_ current-amount.

> instead of the value of current-amount. Is there a better way to build
> the list? At this moment it is not a problem, but when I want to build
> a list from 30 values ...

I would really recommend taking a look at the Introduction to Elisp

(info "(eintr)")
Press C-x C-e here --^

This is sort of obvious:

(setq ret-val (list total-amount current-amount))

If you have a large piece of structure around the variable values and
would prefer to write it in its unevaluated form, you can also use

(setq ret-val `(,total-amount ,current-amount))

namely backquote the entire structure, and put a comma before everything
within the structure that is to evaluated instead of quoted.  After
byte-compilation, the resulting code is rather the same.

David Kastrup

reply via email to

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