Comment on Q about Exercise 10.4 in "ANSI Common Lisp"parentComments−paul_reinersOP18yI'm not sure, but I think you need to use labels, rather than flet, in this case, since local functions defined using flet cannot be recursive. At least that's how I interpret what it says on page 319.At any rate, this solution works using labels: (defmacro ntimes (n &rest body) (let ((h (gensym)) (g (gensym))) `(let ((,h ,n)) (labels ((ntimes-local (,g) (if (> ,g 0) ,@body) (if (zerop ,g) nil (ntimes-local (1- ,g))))) (ntimes-local ,h))))) (Sorry, but again I don't know how to preserve the formatting of my code in this newsgroup.)−pg18yhttp://news.ycombinator.com/formatdoc
Comments
I'm not sure, but I think you need to use labels, rather than flet, in this case, since local functions defined using flet cannot be recursive. At least that's how I interpret what it says on page 319.
At any rate, this solution works using labels:
(Sorry, but again I don't know how to preserve the formatting of my code in this newsgroup.)http://news.ycombinator.com/formatdoc