>>53
| bag |
bag := Dictionary new.
FileStream fileNamed: 'sample.txt' do: [:file |
 [file atEnd] whileFalse: [
  (file nextLine subStrings: ' ') do: [:str |
   bag at: str put: (bag at: str ifAbsent: [0]) + 1
  ]
 ]
].
bag associationsDo: [:assoc | Transcript showln: assoc]