Created
May 30, 2018 13:21
-
-
Save green-coder/31cc3775ba88176f077bfeced9a12afe 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
(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