複数の亀を使う例(1)

例1:

def circ(len:Int,t:Turtle) {
    repeat(20) {
        t.forward(len)
        t.left(18)
    }
}
circ(10,newTurtle(100,0))    // 亀に名前をつけず、生成したものを直に渡す

例2:

def circ(len:Int,t:Turtle) {
    repeat(20) {
        t.forward(len)
        t.left(18)
    }
}
val t1=newTurtle(100,0)       // 亀に名前をつけるので、あとでもっと動かすこともできる
circ(10,t1)

例3:並行動作の例

def circ(len:Int,t:Turtle) {
    repeat(20) {
        t.forward(len)
        t.left(18)
    }
}
val t1=newTurtle(100,0)
val t2=newTurtle(200,0)
val t3=newTurtle(300,0)
runInBackground {circ(30,turtle0)}
runInBackground {circ(30,t1)}
runInBackground {circ(30,t2)}
runInBackground {circ(30,t3)}