[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.)
- beginnerquestion (nconc), Stefan Huchler, 2017/03/17
- Re: beginnerquestion (nconc), Thien-Thi Nguyen, 2017/03/17
- Re: beginnerquestion (nconc), Yuri Khan, 2017/03/17
- Re: beginnerquestion (nconc), Stefan Huchler, 2017/03/17
- Re: beginnerquestion (nconc), Stefan Monnier, 2017/03/17
- Re: beginnerquestion (nconc), Stefan Huchler, 2017/03/21
- Re: beginnerquestion (nconc), Stefan Huchler, 2017/03/21
- Re: beginnerquestion (nconc), John Mastro, 2017/03/21
- Re: beginnerquestion (nconc), Stefan Huchler, 2017/03/21
- Re: beginnerquestion (nconc), Michael Heerdegen, 2017/03/22
- Re: beginnerquestion (nconc), John Mastro, 2017/03/22
- Re: beginnerquestion (nconc), Michael Heerdegen, 2017/03/21