Created
October 1, 2020 16:51
-
-
Save eigenhombre/e5670bc87fc4f1a62a48b670c880deae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bb | |
(require '[babashka.curl :as curl]) | |
(let [{:keys [body status]} | |
(curl/get "https://projects.fivethirtyeight.com/2020-election-forecast/us_simulations.json") | |
winner-map | |
(->> true | |
(json/parse-string body) | |
first | |
:simulations | |
(map :winner) | |
frequencies)] | |
(doseq [[k v] winner-map] | |
(printf "%12s %3d\n" k v))) |
Thanks! Babashka is so cool for this kind of use case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This would be an unreadable, unmaintainable mess in bash. Well done.