トップ «前の日記(2011-11-08(Tue)) 最新 次の日記(2011-11-19(Sat))» 編集

屑俺日記

僕の備忘録(PC、UN*X、ネットワーク関連が中心)なんです。
自分の書いたところは適当(な時とか)に書き換えますので御了承を。


2011-11-09(Wed) きょうも涼しすぎる晴れ

GNU Smalltalk 再度

チュートリアルを(よ)みながらのgst 続く。
配列はこないだやってみたっけ。

st> x
nil
st> x := Array new: 3
(nil nil nil )
st> x
(nil nil nil )
st> y := x
(nil nil nil )
st> x at: 1 put: 2; at: 3 put: 'foo'
'foo'
st> x
(2 nil 'foo' )
st> y
(2 nil 'foo' )
st> (x at: 1) * (x at: 1)
4
st> x !
(2 nil 'foo' )
st> x
nil
st> y
nil

配列の要素数変更はどうするのか、まだわからない。

<後記>
";" は、一つのオブジェクトに連続してメッセージを送ることを意味する記法で、「カスケード」と称するらしい。
</後記>

それから集合型。

st> x :=  Set new
Set ()
st> x add: 'foo'; add: 3
3
st> x
Set (3 'foo' )
st> x remove: 3
3
st> x
Set ('foo' )
st> x includes: 'foo'
true
st> x includes: 5
false

混ぜられる記法もあるらしい。

st> set := Set new
Set ()
st> array := Array new: 5
(nil nil nil nil nil )
st> set add: 'foo' . array at:2 put: 5
'foo'
5
st> set . array
Set ('foo' )
(nil 5 nil nil nil )

載っていた "yourself" いまいち意味がピンとこないような。

連想配列は、Dictionary

幾分なげやりになってきた。

st> dict := Dictionary new
Dictionary (
)
st> dict at: 'One' put: 3
3
st> dict at: 'One'
3
st> dict at: 'ひとつめ' put: '一つ目'
'一つ目'
st> dict
Dictionary (
	'One'->3
	'ひとつめ'->'一つ目'
)

リンクはご自由にどうぞ。でもURLや内容が変った場合はあしからず。

index.htmlは ここから。