Last active
December 27, 2018 16:39
-
-
Save matason/07f86612f7a21dfbb359b982332a0efd to your computer and use it in GitHub Desktop.
The Magic Roundabout - A Common Lisp story about a circular list, SBCL and save-lisp-and-die
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; Demonstrate SBCL save-lisp-and-die. | |
;;; The characters of the Magic Roundabout are on the Magic Roundabout... on | |
;;; each execution of this program, the roundabout is *rotated* one place and | |
;;; the name of character at that place is printed. | |
;;; First load... | |
;;; sbcl | |
;;; * (load "magic.lisp") | |
;;; (magic) | |
;;; (quit) | |
;;; thereafter... | |
;;; ./magic | |
(defun magic() | |
(when (not (boundp 'roundabout)) | |
(defvar roundabout (list "Dougal" "Zebedee" "Brian" "Ermintrude" "Dylan" "Florence" "Mr Rusty")) | |
(setf (cdr (last roundabout)) roundabout)) | |
(if (not (boundp 'name)) | |
(defvar name nil)) | |
(if (eq nil name) | |
(setf name (first roundabout)) | |
(setf name (nth 1 (member name roundabout)))) | |
(format t "~@a~%" name) | |
(sb-ext:save-lisp-and-die "magic" :toplevel #'magic :executable t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment