Want more features on Pastebin? Sign Up, it's FREE!
Guest

functions with uninterned names in CLISP

By: a guest on Oct 3rd, 2013  |  syntax: Lisp  |  size: 0.50 KB  |  views: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)
clone this paste RAW Paste Data