Created
January 13, 2014 04:18
-
-
Save usure/8394626 to your computer and use it in GitHub Desktop.
A stack in common lisp.
This file contains hidden or 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
(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