Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save green-coder/31cc3775ba88176f077bfeced9a12afe to your computer and use it in GitHub Desktop.
Save green-coder/31cc3775ba88176f077bfeced9a12afe to your computer and use it in GitHub Desktop.
(def my-cat
(fn [rf]
(fn ([] (rf))
([result] (rf result))
([result input]
(reduce (fn [acc val]
(cond
(or (= val :fish)
(= val :heat))
acc
(= val :sleep)
(reduced (reduced acc))
:else
(let [ret (rf acc val)]
(if (reduced? ret)
(reduced ret)
ret))))
result
input)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment