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
Command( | |
name = "fib-tower", | |
desc = "create a tower from the fib numbers", | |
body = args(int ~ material){ case (p, i ~ m) => | |
lazy val fibs: Stream[Int] = 0 #:: 1 #:: fibs.zip(fibs.tail).map{case (i,j) => i+j} | |
val xBlocks: Stream[Block] = p.world.fromX(p.loc) | |
for{ | |
(startBlock,n) <- xBlocks.zip(fibs take i) | |
towerBlock <- startBlock.andBlocksAbove take n | |
} towerBlock changeTo m |
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
new Function1[PlayerInteractEvent, Unit]{ | |
def apply(e:PlayerInteractEvent): Unit = println(e) | |
} | |
(e:PlayerInteractEvent) => println(e) | |
e => println(e) |
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
// The hard way to create a Function object | |
new Function1[PlayerInteractEvent, Unit]{ | |
def apply(e:PlayerInteractEvent): Unit = println(e) | |
} | |
// The easy way | |
(e:PlayerInteractEvent) => println(e) | |
// And in the right context, an even easier way | |
e => println(e) |
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
p ! (s"bc using: $m" + p.name) |
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
( | |
(def roof (bigx bigz smallx smallz y m) | |
(if (eq bigx smallx) unit | |
(begin | |
(corners (loc bigx y bigz) (loc smallx y smallz)) | |
(setall m) | |
(roof (- bigx 1) (- bigz 1) (+ smallx 1) (+ smallz 1) (+ 1 y) m) | |
) | |
) | |
) |
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
( | |
(def roof (bigx bigz smallx smallz y m) | |
(if (eq bigx smallx) unit | |
(begin | |
(corners (loc bigx y bigz) (loc smallx y smallz)) | |
(setall m) | |
(roof (- bigx 1) (- bigz 1) (+ smallx 1) (+ smallz 1) (+ 1 y) m) | |
) | |
) | |
) |
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
( | |
(def closed (c) | |
(or | |
(<= (- (cube-max-x c) (cube-min-x c)) 1) | |
(<= (- (cube-max-z c) (cube-min-z c)) 1) | |
) | |
) | |
(defrec pyramid (c m) | |
(begin | |
(cube-set-walls c m) |
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
sealed trait Value{ val value: Any } | |
case class Closure[V](l:Lambda, env:Env) extends Value{ val value = this } | |
case class ObjectValue(value:Any) extends Value | |
case class DynamicValue(value: () => Value) extends Value | |
case class BuiltinFunction(name: Symbol, eval: (List[Expr], Env) => Value) extends Value { | |
val value = this | |
} |
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
val constructorCall1 = "((new jcdc.pluginfactory.Point 5 6))" | |
val constructorCall2 = "((new jcdc.pluginfactory.Point 5 6 unit))" | |
val instanceCall0 = "((.toString (new jcdc.pluginfactory.Point 5 6)))" | |
val instanceCall1 = """((.invoke1 (new jcdc.pluginfactory.Point 5 6) 0))""" | |
val instanceCall2 = """((.invoke2 (new jcdc.pluginfactory.Point 5 6) 0))""" | |
val instanceCall3 = """((.invoke3 (new jcdc.pluginfactory.Point 5 6) 0 0))""" | |
val staticCall1 = """((java.lang.String/valueOf 5))""" | |
val staticField1 = """(java.lang.Math/PI)""" |
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
(defproject jcdc.pluginfactory.test "0.1.0-SNAPSHOT" | |
:source-paths ["src/main/clojure"] ; where to find source files | |
:test-paths ["src/test/clojure"] ; where to find test files | |
:compile-path "target/clojure-1.4.0/classes" ; for .class files | |
:target-path "target/" ; where to place the project's jar file | |
:aot [jcdc.pluginfactory.test.core] ; what modules to compile | |
:description "just testing" | |
:dependencies [[org.clojure/clojure "1.4.0"]]) |