Created
March 4, 2013 21:57
-
-
Save daviddpark/5086048 to your computer and use it in GitHub Desktop.
Which of the two functions is easier to read/understand?
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 interpose-non-nil-values | |
"Return a string of concatenated values from the param-map in the order of keys, eliminating nil values and separating with the sep argument." | |
[sep param-map keys] | |
(apply str (interpose sep (remove nil? (map #(get param-map %) keys))))) | |
(defn interpose-non-nil-values->> | |
"Same as interpose-non-nil-values, but with thread-last macro. More readable?" | |
[sep param-map keys] | |
(->> | |
(apply str) | |
(interpose sep) | |
(remove nil?) | |
(map #(get param-map %) keys))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like the first one. I'm finding that having everything on one line makes it easier to read.