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

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

RE: beginnerquestion (nconc)


From: Drew Adams
Subject: RE: beginnerquestion (nconc)
Date: Fri, 17 Mar 2017 10:20:55 -0700 (PDT)

> if I have to reverse, wouldnt it be easier that there is some
> sort of: (yreverse sequence) that alters the sequence directly,
> or overwrites it. instead of: (setq sequence (nreverse sequence))

You can write macros to do this kind of thing, if you think
using the usual Lisp cliches is ugly.

(defmacro my-list-var-reverse (list-var)
  "Set variable LIST-VAR to the reverse of its value.
LIST-VAR is a symbol whose `symbol-value' is a list."
  `(setq ,list-var (nreverse ,list-var)))

(setq aaa '(1 2 3 4))
(my-list-var-reverse 'aaa)
(symbol-value 'aaa) ; ==> (4 3 2 1)

(`nreverse' acts only on lists, not on sequences in general.)



reply via email to

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