mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* sample/occur2.rb: reimplemented in modern style. [ruby-dev:39927].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
55a70a94b4
commit
7844ea1c64
2 changed files with 8 additions and 7 deletions
|
@ -1,3 +1,7 @@
|
|||
Mon Dec 28 18:13:26 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
||||
* sample/occur2.rb: reimplemented in modern style. [ruby-dev:39927].
|
||||
|
||||
Mon Dec 28 17:19:37 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
||||
* tool/install-sh: correction by Hiro Asari.
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
# word occurrence listing
|
||||
# usege: ruby occur2.rb file..
|
||||
freq = {}
|
||||
while gets()
|
||||
for word in $_.split(/\W+/)
|
||||
begin
|
||||
freq[word] += 1
|
||||
rescue NameError
|
||||
freq[word] = 1
|
||||
end
|
||||
ARGF.each_line do |line|
|
||||
for word in line.split(/\W+/)
|
||||
freq[word] ||= 0
|
||||
freq[word] += 1
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue