[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looping through arguments &rest
From: |
uzibalqa |
Subject: |
Re: Looping through arguments &rest |
Date: |
Mon, 03 Jul 2023 22:24:32 +0000 |
------- Original Message -------
On Tuesday, July 4th, 2023 at 9:40 AM, Stephen Berman <stephen.berman@gmx.net>
wrote:
> 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
Works well indeed. Then "chart" as argument to "attach" becomes superflous,
right ?
We can go without it.