Skip to content

Instantly share code, notes, and snippets.

@paultag
Created December 7, 2012 18:09
Show Gist options
  • Save paultag/4235162 to your computer and use it in GitHub Desktop.
Save paultag/4235162 to your computer and use it in GitHub Desktop.
python-sunlight in clojure-py
(ns sunup
(:require sunlight))
(defn frequencies [coll]
(reduce (fn [counts x] (assoc counts x (inc (get counts x 0)))) {} coll))
(print
(frequencies
(for [l (kwapply
(.-legislators sunlight/openstates)
{"state" "ma"})
] (get l "party"))))
@paultag
Copy link
Author

paultag commented Dec 7, 2012

Output:

{Republican 37, Democratic 161}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment