Skip to content

Instantly share code, notes, and snippets.

View lufia's full-sized avatar

KADOTA, Kyohei lufia

View GitHub Profile
@yashigani
yashigani / brainfuck.hs
Created March 18, 2014 13:40
Brainfuck on Haskell(only Hello, world...)
helloworld = "+++++++++[>++++++++>+++++++++++>+++++<<<-]>.>++.+++++++..+++.>-.------------.<++++++++.--------.+++.------.--------.>+."
type Code = (String, String)
type Pointer = ([Int], [Int], [Int])
parse :: Code -> Pointer -> Pointer
parse ([], _) p = p
parse ('>':xs, bs) p = parse (xs, '>':bs) $ incrementP p
parse ('<':xs, bs) p = parse (xs, '<':bs) $ decrementP p
parse ('+':xs, bs) p = parse (xs, '+':bs) $ increment p