Skip to content

Instantly share code, notes, and snippets.

@mgadzhi
Created February 26, 2014 18:53
Show Gist options
  • Save mgadzhi/9235956 to your computer and use it in GitHub Desktop.
Save mgadzhi/9235956 to your computer and use it in GitHub Desktop.
(ns algo.stack)
(defn make-stack [] {:first nil})
(defn is-empty? [stack] (nil? (:first stack)))
(defn stack-push [stack item]
(let [previous (:first stack)]
{:first
{:item item :next previous}}))
(defn stack-pop [stack]
(:next (:first stack)))
(defn stack-popped [stack]
(:item (:first stack)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment