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!
| Haskell is cool! | |
| Here are some reasons why. | |
| (This is a Literate Haskell file, so you can load it and then follow | |
| along with the examples by running `ghci whyhaskelliscool.lhs`) | |
| "Pattern matching" syntax for defining functions is cool, letting you | |
| avoid 'if' statements and simply write out the different behaviors of | |
| a function: |
| * * * * * osascript -e 'if application "Evernote" is running then tell application "Evernote" to synchronize' |
| <head> | |
| <title>Leaderboard</title> | |
| </head> | |
| <body> | |
| <div id="outer"> | |
| {{> leaderboard}} | |
| </div> | |
| </body> |
| for (var v = 0; v < 2*N; v++) { | |
| for (var u = -N; u < N; u++) { | |
| var w = getCube(u, v); | |
| if (w > 0 && w < tick) { // there's a cube and it's not one we just created | |
| setCube(u, v, 0); // remove it | |
| if (u < N && v > 0) { | |
| if (Math.random() < 0.5) // 50% of the time | |
| setCube(u + 1, v - 1, tick); // directly above | |
| if (Math.random() < 0.25) // 25% of the time | |
| setCube(u + 1, v - 2, tick); // above-left |
| dedup [] = [] | |
| dedup (x:xs) = dedup' x xs | |
| where | |
| dedup' x [] = [x] | |
| dedup' x (x:xs) = dedup' x xs | |
| dedup' y (x:xs) = y : dedup' x xs |
| import qualified Data.Maybe as Maybe | |
| import qualified Control.Monad.Reader as Reader | |
| type Environment = [(String, String)] | |
| get :: String -> Environment -> String | |
| get k env = Maybe.fromJust $ lookup k env |
First, install VirtualBox. Then:
brew update
brew upgrade
brew install docker boot2docker
mkdir ~/.boot2docker
curl http://static.dockerfiles.io/boot2docker-v1.1.2-virtualbox-guest-additions-v4.3.12.iso \
> ~/.boot2docker/boot2docker.iso| liftM f m = m >>= (return . f) | |
| liftM f m = do | |
| a <- m | |
| return (f a) | |
| -- which is just sugar for: | |
| liftM f m = | |
| m >>= \a -> |