Letter frequency: Difference between revisions

Content added Content deleted
Line 5,560: Line 5,560:
select:[:assoc | assoc value isLetter ]
select:[:assoc | assoc value isLetter ]
thenDo:[:assoc | assoc printCR].</lang>
thenDo:[:assoc | assoc printCR].</lang>
If the file is huge, you may not want to read it in as a big string first, but directly feed the chars into the bag:
If the file is huge, you may not want to read it in as a big string first, but feed the chars linewise into the bag:
<lang smalltalk>bagOfChars := Bag new.
<lang smalltalk>bagOfChars := Bag new.
'someFile' asFilename readingLinesDo:[:eachLine | bagOfChars addAll:eachLine].
'someFile' asFilename readingLinesDo:[:eachLine | bagOfChars addAll:eachLine].