Skip to content

Instantly share code, notes, and snippets.

@johntyree
johntyree / DrSyzygy_and_category_theory.txt
Created September 15, 2012 20:55
DrSyzygy and Category Theory
<hiptobecubic> @src Maybe
<lambdabot> data Maybe a = Nothing | Just a
<hiptobecubic> @src Monad
<lambdabot> class Monad m where
<lambdabot> (>>=) :: forall a b. m a -> (a -> m b) -> m b
<lambdabot> (>>) :: forall a b. m a -> m b -> m b
<lambdabot> return :: a -> m a
<lambdabot> fail :: String -> m a
<hiptobecubic> @src [] (>>)
<lambdabot> xs >> ys = concatMap (const ys) xs
@zipcode
zipcode / Brainfuck.scala
Created March 6, 2012 22:32
A quick, dirty and *untested* brainfuck interpreter.
import scala.collection.mutable.Queue
object Brainfuck {
def main(args: Array[String]) {
val code = io.Source.fromFile("src.txt") filter ("[]<>.,+-" contains _) toSeq
exec(code)
}
def exec(code: Seq[Char]) {