Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| Feature: search for movies by director | |
| As a movie buff | |
| So that I can find movies with my favorite director | |
| I want to include and serach on director information in movies I enter | |
| Background: movies in database | |
| Given the following movies exist: | |
| | title | rating | director | release_date | |
| package streams | |
| import common._ | |
| trait GameDef { | |
| case class Pos(x: Int, y: Int) { | |
| def dx(d: Int) = copy(x = x + d, y) | |
| def dy(d: Int) = copy(x, y = y + d) |
| # First, try to get question body with default filter | |
| μ> (fmap head . askSE $ questionsOnUsers [972985] <> site "stackoverflow" ) >>= (^! field "body") :: IO String | |
| *** Exception: user error (key "body" not present) | |
| # Okay, create appropriate filter for this task and get its name | |
| μ> (askSE $ createFilter ["question.body"] [] "default") >>= (^! field "items" . fields "filter") :: IO [String] | |
| ["!9hnGssGO4"] | |
| # See | |
| μ> (fmap head . askSE $ questionsOnUsers [972985] <> site "stackoverflow" <> filter "!9hnGssGO4") >>= (^! field "body") :: IO String |
| ''' | |
| (c) 2011, 2012 Georgia Tech Research Corporation | |
| This source code is released under the New BSD license. Please see | |
| http://wiki.quantsoftware.org/index.php?title=QSTK_License | |
| for license details. | |
| Created on March, 5, 2012 | |
| @author: Sourabh Bajaj | |
| @contact: sourabhbajaj90@gmail.com |