News for hackers. Stuff that matters.
Re:Is it possible to write c...r in lisp, for any combinatio... by lnostdal on Sunday October 11, 2009 @08:20AM (#874672)
quick and dirty; i'm not even sure it is correct:

(defmacro blah (arg body) (with-input-from-string (stream (reverse (string arg))) (dolist (char (loop :for char = (read-char stream nil) :while (and char (or (char= char #\A) (char= char #\D) (error "BLAH: Only A or D is accepted."))) :collect char)) (case char (#\A (setf body `(car ,body))) (#\D (setf body `(cdr ,body))))) body))

CL-USER> (let ((data '((42)))) (blah aa data)) 42 CL-USER>

..manipulate the reader using read-macros (see TCR's new named-readtables library) if you want anything fancier. check out this btw.; http://groups.google.com/group/comp.lang.lisp/msg/d2425c92ce...

edit: the web still doesn't work as i want it to work .. i'm not going to bother fixing the whitespace etc. here

There are no comments on this comment yet.