Fix peek-stack for false on boolean stack

This commit is contained in:
Lee Spector 2020-11-23 09:57:04 -05:00
parent f47e5e924a
commit a8e9de97ce
2 changed files with 6 additions and 3 deletions

3
.gitignore vendored
View File

@ -10,3 +10,6 @@ pom.xml.asc
/.nrepl-port /.nrepl-port
.hgignore .hgignore
.hg/ .hg/
out
notes
.idea/

View File

@ -38,9 +38,9 @@
;; Returns the top item on the stack ;; Returns the top item on the stack
(defn peek-stack (defn peek-stack
[state stack] [state stack]
(if-let [top-item (first (get state stack))] (if (empty? (get state stack))
top-item :no-stack-item
:no-stack-item)) (first (get state stack))))
;; Returns the top n items on the stack, as a chunk. If there are less than n ;; Returns the top n items on the stack, as a chunk. If there are less than n
;; items on the stack, returns the entire stack ;; items on the stack, returns the entire stack