* Looping through arguments &rest
@ 2023-07-03 20:32 uzibalqa
2023-07-03 21:40 ` Stephen Berman
0 siblings, 1 reply; 3+ messages in thread
From: uzibalqa @ 2023-07-03 20:32 UTC (permalink / raw)
To: uzibalqa via Users list for the GNU Emacs text editor
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)))
I want to have the equivalent to
(push entry1 chart)
(push entry2 chart)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Looping through arguments &rest
2023-07-03 20:32 Looping through arguments &rest uzibalqa
@ 2023-07-03 21:40 ` Stephen Berman
2023-07-03 22:24 ` uzibalqa
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Berman @ 2023-07-03 21:40 UTC (permalink / raw)
To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Looping through arguments &rest
2023-07-03 21:40 ` Stephen Berman
@ 2023-07-03 22:24 ` uzibalqa
0 siblings, 0 replies; 3+ messages in thread
From: uzibalqa @ 2023-07-03 22:24 UTC (permalink / raw)
To: Stephen Berman; +Cc: uzibalqa via Users list for the GNU Emacs text editor
------- 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-03 22:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-03 20:32 Looping through arguments &rest uzibalqa
2023-07-03 21:40 ` Stephen Berman
2023-07-03 22:24 ` uzibalqa
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.