comparison lisp/cl.el @ 3355:721daee0fcd8

[xemacs-hg @ 2006-04-23 20:12:25 by aidan] Take on board feedback from Stephen on my last changes.
author aidan
date Sun, 23 Apr 2006 20:12:31 +0000
parents 29234c1a76c7
children 8f1ee2d15784
comparison
equal deleted inserted replaced
3354:15fb91e3a115 3355:721daee0fcd8
157 (if (symbolp place) 157 (if (symbolp place)
158 `(car (prog1 ,place (setq ,place (cdr ,place)))) 158 `(car (prog1 ,place (setq ,place (cdr ,place))))
159 (cl-do-pop place))) 159 (cl-do-pop place)))
160 160
161 (defmacro push (newelt listname) 161 (defmacro push (newelt listname)
162 "Add NEWELT to the list stored in LISTNAME. 162 "Add NEWELT at the beginning of the list stored in LISTNAME.
163 Analogous to (setf LISTNAME (cons NEWELT LISTNAME)), though more careful about 163 Analogous to (setf LISTNAME (cons NEWELT LISTNAME)), though more careful
164 evaluating each argument only once and in the right order. LISTNAME may 164 about evaluating each argument only once and in the right order. LISTNAME
165 be a symbol, or any generalized variable allowed by `setf'." 165 may be a symbol, or any generalized variable allowed by `setf'; that is, it
166 does not necessarily have to be a list, though `push' is most often used on
167 lists. "
166 (if (symbolp listname) `(setq ,listname (cons ,newelt ,listname)) 168 (if (symbolp listname) `(setq ,listname (cons ,newelt ,listname))
167 (list 'callf2 'cons newelt listname))) 169 (list 'callf2 'cons newelt listname)))
168 170
169 (defmacro pushnew (newelt listname &rest keys) 171 (defmacro pushnew (newelt listname &rest keys)
170 "Add NEWELT to the list stored in LISTNAME, unless it's already there. 172 "Add NEWELT at the beginning of LISTNAME, unless it's already in LISTNAME.
171 Like (push NEWELT LISTNAME), except that the list is unmodified if NEWELT is 173 Like (push NEWELT LISTNAME), except that the list is unmodified if NEWELT is
172 `eql' to an element already on the list. 174 `eql' to an element already on the list.
173 Keywords supported: :test :test-not :key" 175 Keywords supported: :test :test-not :key"
174 (if (symbolp listname) (list 'setq listname 176 (if (symbolp listname) (list 'setq listname
175 (list* 'adjoin newelt listname keys)) 177 (list* 'adjoin newelt listname keys))