Skip to content

Instantly share code, notes, and snippets.

@MarkArts
Last active April 19, 2016 13:10
Show Gist options
  • Save MarkArts/479c7efd8811d8850b36da7868fc014f to your computer and use it in GitHub Desktop.
Save MarkArts/479c7efd8811d8850b36da7868fc014f to your computer and use it in GitHub Desktop.
Lisp Fib and Hanoi fun for Structure and Interpretation of computer languages course
(defun fib (n)
(loop repeat n
with p = 0 with q = 1
do(psetq p q
q (+ p q))
collect q
)
)
(print (last (fib 1000)))
(defun printMove (from to)
(print (concatenate `string "Move from: " (write-to-string from) " To: " (write-to-string to) ))
)
(defun move (amount from to spare)
(cond
((= 1 amount)
(printMove from to)
)
(T
(move (1- amount) from spare to)
(move 1 from to spare)
(move (1- amount) spare to from)
)
)
)
(move 3 1 2 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment