Advertisement
Guest User

functions with uninterned names in CLISP

a guest
Oct 3rd, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.50 KB | None | 0 0
  1. (defmacro define-some-things ()
  2.   (let ((f1 (gensym "fun1"))
  3.         (f2 (gensym "fun2")))
  4.     `(progn
  5.        (defun start (n)
  6.          (,f1 n))
  7.        (defun ,f1 (n)
  8.          (if (zerop n)
  9.              (list ',f1 n)
  10.              (cons ',f1 (,f2 (1- n)))))
  11.        (defun ,f2 (n)
  12.          (if (zerop n)
  13.              (list ',f2 n)
  14.              (cons ',f2 (,f1 (1- n))))))))
  15.  
  16. (define-some-things)
  17.  
  18. ; CL-USER> (start 4)
  19. ; (#:|fun137185| #:|fun237186| #:|fun137185| #:|fun237186| #:|fun137185| 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement