新年最初のプログラミングは、Ioでした。
さて、Io2日目ですが、正月ボケでめっちゃつかれまして、
すごく中途半端なところで力尽きました;;
やった軌跡だけ残しておきます。
while文とfor文の制御構文と、
演算子を追加しました。
以下、ログ
C:\Users\->io
Io 20110905
Io>
==> nil
Io> i := 1
==> 1
Io>
==> nil
Io> i slotNames
==> list()
Io> i type
==> Number
Io> while( i <= 11, i println; i = i + 1); "This one goes up to 11" println
1
2
3
4
5
6
7
8
9
10
11
This one goes up to 11
==> This one goes up to 11
Io> for(i,1,11,i println); "This one goes up to 11" println
1
2
3
4
5
6
7
8
9
10
11
This one goes up to 11
==> This one goes up to 11
Io> OperatorTable
==> OperatorTable_0x1364f48:
Operators
0 ? @ @@
1 **
2 % * /
3 + -
4 << >>
5 < <= > >=
6 != ==
7 &
8 ^
9 |
10 && and
11 or ||
12 ..
13 %= &= *= += -= /= <<= >>= ^= |=
14 return
Assign Operators
::= newSlot
:= setSlot
= updateSlot
To add a new operator: OperatorTable addOperator("+", 4) and implement the + message.
To add a new assign operator: OperatorTable addAssignOperator("=", "updateSlot") and implement the updateSlot message.
Io> OperatorTable addOperator("xor",11)
==> OperatorTable_0x1364f48:
Operators
0 ? @ @@
1 **
2 % * /
3 + -
4 << >>
5 < <= > >=
6 != ==
7 &
8 ^
9 |
10 && and
11 or xor ||
12 ..
13 %= &= *= += -= /= <<= >>= ^= |=
14 return
Assign Operators
::= newSlot
:= setSlot
= updateSlot
To add a new operator: OperatorTable addOperator("+", 4) and implement the + message.
To add a new assign operator: OperatorTable addAssignOperator("=", "updateSlot") and implement the updateSlot message.
Io> true xor := method(bool, if(bool, false, true))
==> method(bool,
if(bool, false, true)
)
Io> false xor := method(bool, if(bool, true, false))
==> method(bool,
if(bool, true, false)
)
Io> true xor true
==> false
Io> true xor false
==> true
Io> false xor true
==> true
Io> false xor false
==> false
Io>
今年もよいお年になりますように。