[Audacity-nyquist] Push and macros
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
From: David R. S. <dav...@sh...> - 2006-04-06 08:08:25
|
In line with my previous question about pushing a value onto the end (rather than the start) of a list, I took a look at the def for push: (defmacro push (val lis) `(setf ,lis (cons ,val ,lis))) and wrote a macro I call pushlast, which appears to work: (defmacro pushlast (val lis) `(setf ,lis (reverse (cons ,val (reverse ,lis))))) Apart from the fact it produces the desired result: > (setf mylist (list 1 2 3)) (1 2 3) > (pushlast 4 mylist) (1 2 3 4) is there anything wrong with this? This is my first macro-writing attempt, I haven't used the comma or accent symbols previously, but followed the pattern in push. Thanks David |