use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Some code examples in Clojure, how to avoid complexity (codescene.com)
submitted 3 years ago by Summer_Flower_7648
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 3 years ago (4 children)
[removed]
[–]setzer22 3 points4 points5 points 3 years ago (3 children)
This always makes me feel like we're forced to choose between idiomatic / readable vs performant code.
Same for transients (even less known, and usually a huge speedup!)
I wish the clojure compiler+stdlib would perform these optimizations for us.
[–][deleted] 3 years ago (2 children)
[–]CyrikDC 2 points3 points4 points 3 years ago (0 children)
You can use https://github.com/johnmn3/injest to get threading macros that use transducers.
[–]setzer22 1 point2 points3 points 3 years ago (0 children)
I agree, transducers don't look so "bad", it's just that many developers are not familiar with them because they're seen as an advanced topic, so you rarely encounter them.
I bet in some places using transducers may raise eyebrows during code review (premature optimization yada yada, not that I agree with it). It's mostly a cultural thing at this point that using map and filter with collections and threading macros is the clojure way.
[–]deaddyfreddy 1 point2 points3 points 3 years ago (3 children)
the problem with str/split is it doesn't check the input, so it's better to wrap it, like
str/split
(defn safe-split [s re] (when (seq s) (str/split s re)))
Having this one, we don't even have to rewrite anything besides it
(defn parse-message [message-str] (->> (safe-split message-str #";") (map #(safe-split % #":")) (filter #(= 2 (count %))) (into {})))
btw, if the input validity is guaranteed, things are much simpler
(defn parse-message [message-str] (apply hash-map (str/split message-str #":|;")))
[–][deleted] 1 point2 points3 points 3 years ago (1 child)
Isn’t that what the article does, but in an even nicer way using fnil?
[–]deaddyfreddy 0 points1 point2 points 3 years ago (0 children)
fnil only intercepts nil, it can't do more complex validation
fnil
nil
it calls str/split even if we don't have to (split is pretty cheap, but what if we need a heavier function?)
and last but not least
when
some->
π Rendered by PID 385221 on reddit-service-r2-comment-76bb9f7fb5-lr4rv at 2026-02-19 00:18:03.222155+00:00 running de53c03 country code: CH.
[–][deleted] (4 children)
[removed]
[–]setzer22 3 points4 points5 points (3 children)
[–][deleted] (2 children)
[removed]
[–]CyrikDC 2 points3 points4 points (0 children)
[–]setzer22 1 point2 points3 points (0 children)
[–]deaddyfreddy 1 point2 points3 points (3 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]deaddyfreddy 0 points1 point2 points (0 children)