Created
August 13, 2015 00:05
-
-
Save dabd/0d664d953d633eff8705 to your computer and use it in GitHub Desktop.
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
(defprotocol PStack | |
"A stack protocol" | |
(push [this val] "Push element in") | |
(pop* [this] "Pop element from stack") | |
(top [this] "Get top element from stack")) | |
(defrecord FStack [coll] | |
PStack | |
(push [_ val] | |
"Return the stack with the new element inserted" | |
(FStack. (conj coll val))) | |
(pop* [_] | |
"Return the stack without the top element" | |
(FStack. (rest coll))) | |
(top [_] | |
"Return the top value of the stack" | |
(first coll))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment