Skip to content

Instantly share code, notes, and snippets.

@daviddpark
Created March 4, 2013 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviddpark/5086048 to your computer and use it in GitHub Desktop.
Save daviddpark/5086048 to your computer and use it in GitHub Desktop.
Which of the two functions is easier to read/understand?
(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)))
@azumafuji
Copy link

I like the first one. I'm finding that having everything on one line makes it easier to read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment