I'm getting more comfortable in Clojure as I work through AoC 2024. It's interesting not having the LOOP macro to fall back on. Even though there's nothing unique to Clojure in my solution, the language pushed me to a more functional approach instead of just using mutable counters.
I ended up using reduce to traverse the grid of characters, and wrote a higher-order function to generically handle looking for XMAS/SAMX in all four directions. I'll have to read up on what macro support there is in Clojure, as that function probably could have been a macro to cut down on the runtime cost:
https://github.com/coderfrog256/AdventOfCode/blob/main/2024/clojure/src/clojure_aoc/Day4.clj
The only thing I'm not a fan of so far is the performance. I'm using the configuration that comes with Doom Emacs, and the solution's taking ~140ms to complete in my REPL whereas the Common Lisp solution takes ~4ms without any optimization declarations.
Hopefully there's some equivalent to (optimize (speed 3) (safety 0))...
#adventofcode #clojure #programming #functionalprogramming