這是Squeak(Smalltalk)有關數字的語法
| x |
x := 5 + 3.
x := 5 - 3.
x := 5 * 3.
x := 5 / 3.
x := 5.0 / 3.0.
x := 5.0 // 3.0.
x := 5.0 \\ 3.0.
x := -5.
x := 5 sign.
x := 5 negated.
x := 3.14 integerPart.
x := 3.14 fractionPart.
x := 5 reciprocal.
x := 5 squared.
x := 25 sqrt.
x := 5 raisedTo: 2.
x := 5 raisedToInteger: 2.
x := 10 exp.
x := -5 abs.
x := 3.14 rounded.
x := 3.14 truncated.
x := 3.14 roundTo: 1.
x := 3.14 truncateTo: 1.
x := 3.14 floor.
x := 3.14 ceiling.
x := 5 factorial.
x := 99 atRandom.
x := 360 degreesToRadians.
x := 3.14 radiansToDegrees.
下圖中的[run code]指令積木是我自己DIY的.專門用來跑Squeak code的,叔叔有練過的,小朋友不要亂試,右邊則是數字處理的結果List列表
寄件者 scratchlab |
沒有留言:
張貼留言