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
(defn partial-right | |
"Takes a function f and fewer than the normal arguments to f, and | |
returns a fn that takes a variable number of additional args. When | |
called, the returned function calls f with additional args + args." | |
([f] f) | |
([f arg1] | |
(fn [& args] (apply f (concat args [arg1])))) | |
([f arg1 arg2] | |
(fn [& args] (apply f (concat args [arg1 arg2])))) | |
([f arg1 arg2 arg3] |
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
(defmacro return-or [sym expr] {:pre [(symbol? sym)]} | |
`(if (reduced? ~sym) (unreduced ~sym) ~expr)) | |
(defn imp-block [[expr & tail-exprs]] | |
(match expr | |
(('let pattern init) :seq) | |
(if-not tail-exprs | |
(list init) | |
(match (imp-block tail-exprs) |