thread-first
Navigation
thread-first ->
is ideal for navigating large, nested structures.
(-> results :matches (nth 3) :scores (get "total_points"))
This works with Java objects too
(-> results .getMatches (nth 3) .getScores (.getKey "total_points"))
Transformation
The second use case of ->
is performing a series of functional transformations on a single value:
(-> username string/trim string/lower-case (string/replace #"[^a-z]" "-"))
(-> game-state (assoc :next-player :player2) (update :turn-counter inc) (update-in [:scores :player1] + 10) (update-in [:scores :player2] - 3))