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
/** | |
* <b>Fixed Point Combinator is:</b> | |
* Y = λf.(λx.f (x x)) (λx.f (x x)) | |
* | |
* <b>Proof of correctness:</b> | |
* Y g = (λf . (λx . f (x x)) (λx . f (x x))) g (by definition of Y) | |
* = (λx . g (x x)) (λx . g (x x)) (β-reduction of λf: applied main function to g) | |
* = (λy . g (y y)) (λx . g (x x)) (α-conversion: renamed bound variable) | |
* = g ((λx . g (x x)) (λx . g (x x))) (β-reduction of λy: applied left function to right function) | |
* = g (Y g) (by second equality) [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 scala.util.parsing.combinator._ | |
import scala.collection.mutable._ | |
object Bf extends Application { | |
private val data = ArrayBuffer[Char]() // TODO fill | |
private var pointer = 0 | |
private var in: String = "" | |
private var _init = false | |
private def getNextInput() = { |
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
trait Monad[+M[_]] { | |
def unit[A](a: A): M[A] | |
def bind[A, B](m: M[A])(f: A => M[B]): M[B] | |
} | |
// probably only works in Scala 2.8 | |
implicit def monadicSyntax[M[_], A](m: M[A])(implicit tc: Monad[M]) = new { | |
private val bind = tc.bind(m) _ | |
def map[B](f: A => B) = bind(f compose tc.unit) |
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
trait ~>[F[_],G[_]] { | |
def apply[A](a: F[A]): G[A] | |
} | |
type Id[A] = A | |
def apply[B](f: Id ~> List, b: B, s: String): (List[B], List[String]) = (f(b), f(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
// haskell: | |
// data Bool = False | True | |
// scala | |
sealed abstract class Bool | |
case object True extends Bool | |
case object False extends Bool |
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
-- First | |
return a >>= k = k a | |
-- Second | |
m >>= return = m | |
-- Third | |
m >>= (\x -> f x >>= g) = (m >>= f) >>= g |
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
reset { | |
// A | |
shift { cf: (Int=>Int) => | |
// B | |
val eleven = cf(10) | |
// E | |
println(eleven) | |
val oneHundredOne = cf(100) | |
// H | |
println(oneHundredOne) |
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
-- static Peano constructors and numerals | |
data Zero | |
data Succ n | |
type One = Succ Zero | |
type Two = Succ One | |
type Three = Succ Two | |
type Four = Succ Three |
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
trait λ { type ap[_<:λ]<:λ } | |
type I = λ{type ap[X<:λ] = X } | |
type K = λ{type ap[X<:λ] = λ{type ap[Y<:λ] = X }} | |
type S = λ{type ap[X<:λ] = λ{type ap[Y<:λ] = λ{type ap[Z<:λ] = X#ap[Z]#ap[Y#ap[Z]] }}} | |
type Y = S#ap[I]#ap[I]#ap[S#ap[I]#ap[I]] |
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
!! fonts | |
Xft.dpi: 86 | |
Xft.antialias: true | |
Xft.autohint: false | |
Xft.hinting: true | |
! hintnone, hintslight, hintmedium, hintfull | |
Xft.hintstyle: hintmedium | |
Xft.rgba: rgb | |
! lcdnone, lcddefault, lcdlight, lcdlegacy | |
Xft.lcdfilter: lcddefault |
OlderNewer