r/Clojure • u/miran1 • Dec 01 '24
Advent of Clojure
Advent of Code has started today.
Who is using Clojure to write the solutions? Share the links your repositories!
62
Upvotes
r/Clojure • u/miran1 • Dec 01 '24
Advent of Code has started today.
Who is using Clojure to write the solutions? Share the links your repositories!
View all comments
Show parent comment
3
u/joinr Dec 02 '24
There's an identity that can simplify the code a little and win points at code golf tournaments:
If you invoke a hashmap as a function, it's semantically like clojure.core/get, which has an additional arity that accepts a default arg if the key has no associated value.
Just express them the best you can, then figure out how to make them fast or transform to a more efficient algo. More learning opportunity. Eventually you can develop reflexes for faster paths by default (if they are necessary), maybe developing a nice balance of easy and clear / efficient.