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 sys | |
import Event_pb2 | |
event = Event_pb2.Event() | |
if len(sys.argv) != 2: | |
print 'Usage:', sys.argv[0], 'datafile' | |
sys.exit(-1) | |
f = open(sys.argv[1], 'rb') |
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
source "http://rubygems.org" | |
group :development do | |
gem 'rake', '~> 0.9.2' | |
gem 'rack', '~> 1.4.1' | |
gem 'jekyll', '~> 0.11.2' | |
gem 'rdiscount', '~> 1.6.8' | |
gem 'redcarpet', '~> 2.1.1' | |
gem 'maruku', '~> 0.6.1' | |
gem 'pygments.rb', '~> 0.2.12' |
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 where | |
crack = do x <- ['a'..'c'] ; y <- ['a'..'c'] ; z <- ['a'..'c'] ; | |
let { password = [x, y, z] } ; | |
if attempt password | |
then return (password, True) | |
else return (password, False) | |
attempt pw = if pw == "cab" then True else False |
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 where | |
stagger :: (Num t) => t -> t | |
stagger d = d + 2 | |
crawl d = d + 1 | |
treasureMap d = | |
crawl ( | |
stagger ( | |
stagger d)) |
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
def treasure_map(v) | |
v = stagger(v) | |
v = stagger(v) | |
v = crawl(v) | |
return( v ) | |
end |
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
Prelude> return "WHAT" :: Maybe String | |
Just "WHAT" | |
Prelude> Just 9 >>= \x -> return (x*10) | |
Just 90 | |
Prelude> Nothing >>= \x -> return (x*10) | |
Nothing |
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
instance Monad Maybe where | |
return x = Just x | |
Nothing >>= f = Nothing | |
Just x >>= f = f x | |
fail _ = Nothing |
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
Prelude> zip [1 .. 5] ["one", "two", "three", "four", "five"] | |
[(1,"one"),(2,"two"),(3,"three"),(4,"four"),(5,"five")] | |
Prelude> let rightTriangles' = [ (a,b,c) | c <- [1..10], b <- [1..c], a <- [1..b], a^2 + b^2 == c^2] | |
Prelude> rightTriangles' | |
[(3,4,5),(6,8,10)] |
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 where | |
tryIo = do putStr "Enter your name: " ; | |
line <- getLine ; | |
let { backwards = reverse line } ; | |
return ("Hello. Your name backwards is " ++ backwards) |
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 where | |
data Position t = Position t deriving (Show) | |
stagger (Position d) = Position (d + 2) | |
crawl (Position d) = Position (d + 1) | |
rtn x = x | |
x >>== f = f x | |
treasureMap pos = pos >>== |