Re: moving an element of a list to another list
Posted: Fri Nov 05, 2010 12:03 pm
See also Anaphora.
Discuss and learn Lisp programming of all dialects. NOTICE: Site locked. No new users or posts.
http://www.lispforum.com/
That is the reason I chose to write a macro, not a function. And, since pop-nth (or steal) is a generalization of pop, which is a macro, it feels more natural to me that it is also pop-nth is coded as a macro. Writing a macro also allows a non-destructive version, which is important if your lists share tails.Warren Wilkinson wrote:There is one problem --- what happens if you steal item 0 from a list? It won't work, and it cannot be made to work because steal is a utility function, and it would be unwise to hardcode it so it would setf *test-input* to (cdr *test-input*) for the zero case.
Just a quibble... That should be "anaphoric," not "anamorphic."Warren Wilkinson wrote:The 'a' stands for anamorphic. Paul Graham's 'On Lisp' has it (and anamorphic if, cond, etc), but I think the technique is older than that still. PG also has the definition of 'with-gensyms'. I won't go into details since PG explains it in that book, which is freely available as a downloadable pdf at http://www.paulgraham.com/onlisp.html.