Adding in another trivial example

This commit is contained in:
Paul R. Tagliamonte 2013-03-15 13:00:28 -04:00
parent 723cf75f73
commit e2ff4a447f
2 changed files with 24 additions and 1 deletions

3
bin/hy
View File

@ -6,7 +6,8 @@ import sys
if len(sys.argv) > 1: if len(sys.argv) > 1:
from hy.importer import import_file_to_module from hy.importer import import_file_to_module
import_file_to_module("__main__", sys.argv[1]) sys.argv.pop(0)
import_file_to_module("__main__", sys.argv[0])
sys.exit(0) # right? sys.exit(0) # right?

22
eg/sunlight/party-count.hy Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env hy
; let's check out the party breakdown for a state
(import sys)
(import-from sunlight openstates)
(import-from 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*))