View AutoDiff.scala
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
package autodiff | |
import org.scalatest._ | |
import org.scalatest.Assertions._ | |
import scala.collection.mutable._ | |
class AutoDiffSpec extends FunSuite { | |
// computation graph (list of nodes) |
View CollapsingTowers.scala
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
/* collapsing multiple levels of interpreters */ | |
object TestMeta3 { | |
abstract class Exp | |
case class Lit(n:Int) extends Exp | |
case class Sym(s:String) extends Exp | |
case class Var(n:Int) extends Exp | |
case class App(e1:Exp, e2:Exp) extends Exp | |
case class Lam(e:Exp) extends Exp |
View GenericLifiting.scala
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 language.experimental.macros | |
import language.dynamics | |
import scala.reflect.macros._ | |
case class Rep[+T](x:String) | |
implicit def anyToRep[T](x:T) = new Rep[T](x.toString) | |
class ShouldLift[T] |
View FixingQuasiquotes.scala
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
package test1 | |
/* | |
====================================================================== | |
fixing quasi-quotes | |
====================================================================== | |
when writing a program using quasi-quotation: | |
val x = c"foo()" |