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 bash | |
# Blacklist commit 1abfdd7 | |
root=$(awk '{print $2}') | |
objects=$(git rev-list --objects $root | awk '{print $1}') | |
echo $objects | grep 1abfdd7cb8c67ead50757ea596aa0f01b0ab1389 > /dev/null | |
if [[ $? -eq 0 ]] | |
then |
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
import System.Environment | |
sumSquares :: (Integral a) => a -> a | |
sumSquares n = n*(n+1)*(2*n+1) `div` 6 | |
sumCubes :: (Integral a) => a -> a | |
sumCubes n = ((n^2 + n) `div` 2)^2 | |
main = do | |
args <- getArgs |
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
import Control.Monad | |
import Control.Monad.State.Lazy | |
-- Simple way to get Fibonacci numbers using monad transformers | |
fibT :: (Monad m, Num a) => StateT a (StateT a m) () | |
fibT = get >>= \x -> lift get >>= \y -> put y >> (lift . put $ x + y) | |
-- Get the nth Fibonacci number | |
fib :: Num a => Int -> a | |
fib n = execState (execStateT (replicateM_ n fibT) 0) 1 |
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
import itertools | |
# Monad instance on a Python iterator, very similar to Haskell's list monad. | |
# In general, Haskell typeclass instances can be regarded as dictionaries which | |
# map the implemented function to its implementation. For a good explanation of | |
# this, see Philip Wadler's "Faith, Evolution, and Programming Languages" | |
# lecture. What this means for us is that we can write a function whose type | |
# signature in Haskell would be: | |
# Monad m => f m | |
# |
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
import Control.Monad | |
import Control.Monad.Identity (runIdentity) | |
import Control.Monad.Error | |
import Control.Monad.State.Lazy | |
import Data.Maybe (listToMaybe) | |
-- |Monad transformer which stores a stack internally | |
type StackT s m = StateT [s] m |
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
module Main (main) where | |
import Control.Monad | |
import Data.Char | |
import System.IO | |
import System.Environment | |
import System.Random | |
import System.Exit |
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
#include "dict.h" | |
/* Initializes the hash table at table. | |
* Arguments: | |
* | |
* init_size: the initial number of chains in the hash table. If 0, defaults | |
* to a hardcoded value. | |
* key_hash: a hashing function that operates on keys | |
* key_eq: function which returns nonzero iff two keys are equal. | |
* |
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
from functional import fun | |
from itertools import imap, ifilter, takewhile, count | |
@fun(2) | |
def add(x,y): return x + y | |
# Here I define a function which takes a string and shows what it evaluates to. | |
@fun(1) | |
def evalPrint(s): | |
print "%s -> %s" % (s, eval(s)) |
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
#lang racket | |
; Solution to Project Euler problem #23 | |
(require racket/set) | |
; Predicate to check if m | n | |
(define (divides? m n) | |
(= 0 (modulo n m))) |
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
API_HANDLERS = {} | |
def register_handler(func, name=None): | |
if name is None: | |
name=func.__name__ | |
API_HANDLERS[name] = func | |
return func | |
def dispatch(name, request): | |
return API_HANDLERS[name](request) |
OlderNewer