Skip to content

Instantly share code, notes, and snippets.

@usure
Created January 13, 2014 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usure/8394626 to your computer and use it in GitHub Desktop.
Save usure/8394626 to your computer and use it in GitHub Desktop.
A stack in common lisp.
(defparameter *stack*
(list 0))
(defun push-to-stack (&rest args)
"This pushes any number of arguments to the stack."
(dolist (arg args)
(push arg *stack*)
(print "ok")))
(defun pop-stack (&rest args)
"This remove any number of pieces from the stack."
(dolist (arg args)
(defparameter *stack*
(remove arg *stack*))))
(defun clear-stack ()
(defparameter *stack*
(list 0)))
(defun stack ()
(print *stack*))
(defun add-stack-data ()
(apply #'+ (mapcar #'+ *stack*)))
(pop-stack 10)
(push-to-stack (* 10 10))
(push-to-stack 10)
(push-to-stack "TEXT")
(stack)
(clear-stack)
(add-stack-data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment