Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn chain-fn [f]
- (fn [[c x]]
- (if (= c ::continue)
- (if-let [result (f x)]
- [::continue result]
- [::short-circuit x])
- [::short-circuit x])))
- (defn start-chain [value]
- [::continue value])
- (defn stop-chain [[_ value]]
- value)
- (defn rev [s]
- (println "calling rev")
- (apply str (reverse s)))
- (defn dub [s]
- (println "calling dub")
- (str s s))
- (defn break-it [s] nil)
- (comment
- "Usage:"
- (-> "Meow"
- start-chain
- ((chain dub))
- ((chain break-it))
- ((chain rev))
- stop-chain)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement