Created
April 8, 2015 05:59
-
-
Save johnazariah/ec3b7f8840142866b7f8 to your computer and use it in GitHub Desktop.
Scala Wat
This file contains hidden or 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
type LF = (Argument, State) => (State, Result) | |
case class _then(f : LF) | |
case class _else(f : LF) | |
def _if (ifFunc: LF) (thenFunc: _then) (elseFunc: _else) : LF = | |
(a, state) => ifFunc(a, state) match { | |
case (_, Accepted) => thenFunc.f(a, state) | |
case _ => elseFunc.f(a, state) | |
} | |
def conditionallyCompose(conditionFunc: LF, trueFunc: LF, falseFunc: LF) : LF = | |
_if (conditionFunc) (_then(trueFunc)) (_else(falseFunc)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment