11. Macros
Activity 11.01: A Tennis CSV Macro
Solution:
- Here is one possibility for the expanded code:
(with-open [reader (io/reader csv)] (->> (csv/read-csv reader) sc/mappify (sc/cast-with {:winner_games_won sc/->int :loser_games_won sc/->int}) (map #(assoc % :games_diff (- (:winner_games_won %) (:loser_games_won %)))) (filter #(> (:games_diff %) threshold)) (map #(select-keys % [:winner_name :loser_name :games_diff])) doall))
This should be taken as a rough sketch for the final output.
- Set up your project. The
deps.edn
file should look like this:{:deps &...