From a8e9de97ce57a99d96e0e8c766e129e8feffb843 Mon Sep 17 00:00:00 2001 From: Lee Spector Date: Mon, 23 Nov 2020 09:57:04 -0500 Subject: [PATCH] Fix peek-stack for false on boolean stack --- .gitignore | 3 +++ src/propeller/push/state.cljc | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d18f225..5211373 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ pom.xml.asc /.nrepl-port .hgignore .hg/ +out +notes +.idea/ \ No newline at end of file diff --git a/src/propeller/push/state.cljc b/src/propeller/push/state.cljc index 5026dec..f06bc89 100755 --- a/src/propeller/push/state.cljc +++ b/src/propeller/push/state.cljc @@ -38,9 +38,9 @@ ;; Returns the top item on the stack (defn peek-stack [state stack] - (if-let [top-item (first (get state stack))] - top-item - :no-stack-item)) + (if (empty? (get state stack)) + :no-stack-item + (first (get state stack)))) ;; 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