3 ms·
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 :
by lnostdal 17y ago
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/d2425c92cef7465c 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