This file contains 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 python | |
import collections | |
import sys | |
def tokens(f): | |
for line in f: | |
for t in line.split(): | |
yield t |
This file contains 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
''' | |
Shorthand decorator for the common case of looking up ORM objects from | |
named URL parameters. | |
For each named URL parameter passed to the view of the form | |
``db_table_id``, look up the ORM object in the corresponding model with | |
the given primary key, returning a 404 in case it is not found. | |
For example: |
This file contains 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
(defn evens | |
([] nil) | |
([x] nil) | |
([x y & xs] | |
(lazy-seq (cons y (apply evens xs))))) |
This file contains 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
(defn factorial [n] | |
(reduce * (range 1 (inc n)))) |
NewerOlder