Skip to content

Instantly share code, notes, and snippets.

@tamamu
Created October 17, 2015 16:08
Show Gist options
  • Save tamamu/3233f5742a85c3c28f23 to your computer and use it in GitHub Desktop.
Save tamamu/3233f5742a85c3c28f23 to your computer and use it in GitHub Desktop.
一般的ではないフィボナッチ数を求める方法(CL)
(defmacro let1 (var val &body body)
`(let ((,var ,val))
,@body))
(defun fib-l (n)
(let1 l '(1 0)
(labels ((f (n l)
(if (equal (length l) (1+ n))
(car l)
(f n (cons (+ (car l) (cadr l)) l)))))
(f n l))))
(defun main ()
(print (fib-l 150)))
(declaim (optimize (speed 3) (debug 0) (safety 0)))
(defun make-app ()
#+sbcl (sb-ext:save-lisp-and-die "my-fib-sbcl"
:toplevel #'main
:executable t)
#+ccl (ccl:save-application "my-fib-ccl"
:toplevel-function #'main
:prepend-kernel t))
(make-app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment