第3回例題のプログラム例

例題1 例題1

def circ {
    repeat(20) {forward(10) ; left(18) }
}
clear
repeat(4){
    circ 
    penUp ; forward(50) ; penDown
}

例題2 例題2

def box {
    repeat(4) {forward(100) ; left }
}
clear
repeat(72){ box ; left(5) }

例題3 例題3

def polygon {
    repeat(8) {forward(20) ; left(45) }
} 
clear  // 前進と左回転の順を逆にしてみた
repeat(15){ polygon ; left(15); forward(30)  }

例題4 例題4

def circ(len:Int) {
    repeat(20) {forward(len) ; left(18) }
} //> circ: (len: Int)Unit
clear
circ(10) ; circ(10) ; circ(10) ; circ(10) ; circ(10) //何度やっても同じだが

例題5 例題5

def circ(len:Int) {
    repeat(20) {forward(len) ; left(18) }
} //> circ: (len: Int)Unit
clear
circ(10)
circ(15)
circ(20)
circ(25)
circ(30)

例題6 例題6

def circ(len:Int) {
    repeat(20) {forward(len) ; left(18) }
} //> circ: (len: Int)Unit
clear
circ(10) ; forward(10)
circ(15) ; forward(10)
circ(20) ; forward(10)
circ(25) ; forward(10)
circ(30) ; forward(10)

例題7 例題7

def circx(len:Int) {
    repeat(22) {forward(len) ; left(18) }
} //> circx: (len: Int)Unit
clear
circx(10)
circx(15)
circx(20)
circx(25)
circx(30)
circx(35)
circx(40)