diff options
author | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-09-08 07:09:52 +0000 |
---|---|---|
committer | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-09-08 07:09:52 +0000 |
commit | b1f96af92f5b8519c477de3bd8917e5220442f6b (patch) | |
tree | c29d1f6370f4498547c80a69e0440256eeaf39e7 /sample/occur.rb | |
parent | 48acbc5e03622f1eb0423a6c2a3a603f61acfac6 (diff) |
This commit was manufactured by cvs2svn to create tag 'v1_1d-start'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_1d-start@299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/occur.rb')
-rw-r--r-- | sample/occur.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sample/occur.rb b/sample/occur.rb index 2141fade38..f489beee17 100644 --- a/sample/occur.rb +++ b/sample/occur.rb @@ -1,12 +1,12 @@ # word occurrence listing # usege: ruby occur.rb file.. -freq = {} +freq = Hash.new(0) while gets() for word in $_.split(/\W+/) - freq[word] +=1 + freq[word] += 1 end end -for word in freq.keys.sort - printf("%s -- %d\n", word, freq[word]) +for word in freq.keys.sort! + print word, " -- ", freq[word], "\n" end |