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 | |
#usage: lines.py filenames seperated by space | |
#my personal way of using it: lines.py `git diff --no-ext-diff --name-only HEAD~1 HEAD | grep .py` | |
import sys | |
TAB_WIDTH = 8 | |
LINE_LENGTH = 79 | |
def count(line): |
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
data State s a = State (s -> (a, s)) | |
test :: Int -> State Int () -> State Int () -> State Int Bool | |
test n f g = (f `bindState` (\_ -> g) `bindState` (\_ -> State $ (\s -> ((s > n), s)))) | |
runState (State t) s = t s | |
returnState :: a -> State s a | |
returnState a = State $ (\s -> (a, 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
import System.Random | |
newtype State s a = State { | |
runState :: s -> (a, s) | |
} | |
returnState :: a -> State s a | |
returnState a = State (\s-> (a, s)) | |
bindState :: State s a -> (a -> State s b) -> State s b |
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 Data.List | |
data Piece = X | O deriving (Ord, Eq, Show) | |
data Board = Board [(Int, Int, Piece)] deriving(Ord, Eq,Show) | |
winning_combinations = [[(a,0), (a,1), (a,2)] | a <- [0..2] ] ++ [[(0,a), (1,a), (2,a)] | a <- [0..2] ] ++ [[(0,0), (1,1), (2,2)], [(0,2), (1,1), (2,0)]] | |
over2 :: Board -> Bool | |
over2 (Board []) = False | |
over2 (Board x) = is_winner newx winning_combinations |
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
/*Prolog Num succ and prev defined in some wierd ass JS */ | |
var num= (function(num) { | |
num = num || 0; | |
var x = num; | |
return { | |
s: function() { | |
x+=1; | |
return x; | |
}, |
NewerOlder