w***n 发帖数: 3 | 1 Q:Write Smalltalk code that that reads every line of input into an
array. Then print that array in reverse order.
这个要设计个数列,怎么穿插到下面两个程序中啊,下面的程序是正序打印带列号,这
个要反序打印,我插入了好几次数列,运行的时候都告诉我错误。。。
string.st
! String methods !
fileLinesDo: aBlock
|f last|
f := File name: self.
f readStream linesDo: [:line|
last := aBlock value: line].
f readStream close.
^last !!
z.st
|i|
i := 0.
'eg/0lib.st' fileLinesDo: [:line|
i := i + 1.
(i s, ':', Character tab s, line ) oo]. |
|