tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,23 @@
def makePoint(x, y) {
def point implements pbc {
to __printOn(out) { out.print(`<point $x,$y>`) }
to __optUncall() { return [makePoint, "run", [x, y]] }
to x() { return x }
to y() { return y }
to withX(new) { return makePoint(new, y) }
to withY(new) { return makePoint(x, new) }
}
return point
}
def makeCircle(x, y, r) {
def circle extends makePoint(x, y) implements pbc {
to __printOn(out) { out.print(`<circle $x,$y r $r>`) }
to __optUncall() { return [makeCircle, "run", [x, y, r]] }
to r() { return r }
to withX(new) { return makeCircle(new, y, r) }
to withY(new) { return makeCircle(x, new, r) }
to withR(new) { return makeCircle(x, y, new) }
}
return circle
}

View file

@ -0,0 +1,4 @@
def p := makePoint(0.5, 0.5)
def c := makeCircle(1, 1, 2)
println(p)
println(c)