help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Looping through arguments &rest


From: Stephen Berman
Subject: Re: Looping through arguments &rest
Date: Mon, 03 Jul 2023 23:40:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Mon, 03 Jul 2023 20:32:25 +0000 uzibalqa <uzibalqa@proton.me> wrote:

> Why does "attach" keep "chart" nil
>
> (setq chart '())
> (setq entry1 '("A" "B" "C"))
> (setq entry2 '("D" "E" "F"))
>
> (defun attach (chart &rest linsq)
>   "TODO"
>   (dolist (tbrow linsq)
>     (push tbrow chart)))

The argument `chart' is local to the function `attach', changing it
within the function has no effect on the global variable `chart'.  Also,
`dolist' without a RESULT argument returns nil, so either add `chart' as
RESULT or make `chart' the last line in the function body so it will be
the return value.

> I want to have the equivalent to
>
> (push entry1 chart)
> (push entry2 chart)

Set the value of the global variable `chart' to the result of calling
`attach' (modified as above).

Steve Berman



reply via email to

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