RosettaCodeData/Task/Stack/Common-Lisp/stack.lisp

17 lines
326 B
Common Lisp
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(defstruct stack
elements)
(defun stack-push (element stack)
(push element (stack-elements stack)))
(defun stack-pop (stack)(deftype Stack [elements])
(defun stack-empty (stack)
(endp (stack-elements stack)))
(defun stack-top (stack)
(first (stack-elements stack)))
(defun stack-peek (stack)
(stack-top stack))