Created
December 19, 2016 18:22
-
-
Save rubenfiszel/8c0adcab0945bf2d6966bc21339f44f0 to your computer and use it in GitHub Desktop.
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
case class Lambda[A:Rep, B:Rep](f: A => B) extends (A => B) { | |
val rA = rep[A] | |
val rB = rep[B] | |
type InternalB = rB.Internal | |
lazy val lambda: Exp[rA.Internal => InternalB] = doLambdaDef(f)(rA, rB) | |
def apply(arg:A):B = { | |
implicit val mf = rB.m | |
val apply = Apply(lambda, rA.to(arg)) | |
rB.from(apply) | |
} | |
} | |
def sumIf(x: Lambda[T,Boolean] { type InternalB = scala.Boolean }): Int = { | |
val lambda: Exp[x.rA.Internal => scala.Boolean] = x.lambda | |
int(indexedSeq_sumIf(lambda)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment