Comment detail

続・ファイル内の重複行削除 (Nested Flatten)
Squeak Smalltalk で。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
| in memo currPos line out |
in := FileStream oldFileNamed: 'in.txt'.
memo := Dictionary new.

[   currPos := in position.
    (line := in nextLine) notNil
] whileTrue: [memo at: line hash put: currPos].
in reset.

out := FileStream forceNewFileNamed: 'out.txt'.
memo values sort do: [:pos |
    out nextPutAll: (in position: pos; nextLine); cr].
in close. out edit
なぜか言語欄の選択が投稿に反映されなかったようです。お手数ですが、「Other」→「Smalltalk」への差し替えをお願いいたします。

Index

Feed

Other

Link

Pathtraq

loading...