Created
March 31, 2014 18:17
-
-
Save kurogelee/9898706 to your computer and use it in GitHub Desktop.
Clojureでmapcatのfor版としてforcatを作る(+おまけpapply) ref: http://qiita.com/kurogelee/items/c992d8fe15a21bdb5793
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
user=> (forcat [x (range 3) y [:a :b]] [x] [y]) | |
(0 :a 0 :b 1 :a 1 :b 2 :a 2 :b) |
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 forcat [seq-exprs & body-exprs] | |
`(apply concat (for ~seq-exprs (concat ~@body-exprs)))) |
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 papply [f & args] (apply partial apply f args)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment