hy/eg/sunlight/party-count.hy
Gergely Nagy 494bf0e8ad Remove the import-as and import-from builtins
The new and improved (import) can handle all cases import-as and
import-from did, so drop the latter two from the language. To do this,
the import builtin had to be changed a little: if there's a single
import statement to return, return it as-is, otherwise return a list of
imports.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
2013-04-20 16:06:32 +02:00

25 lines
571 B
Hy
Executable File

#!/usr/bin/env hy
; Copyright (c) Paul R. Tagliamonte <paultag@debian.org>, 2013 under the terms
; of the Expat license, a copy of which you have should have recieved with
; the source.
(import sys)
(import [sunlight [openstates]]
[collections [Counter]])
(def *state* (get sys.argv 1))
(defn get-legislators [state]
(kwapply (.legislators openstates) {"state" state}))
(defn get-party-breakdown [state]
(Counter (map
(lambda [x] (get x "party"))
(get-legislators state))))
(print *state* "-" (get-party-breakdown *state*))