1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Drop duplicated sample code (#2389) [ci skip]

* Drop duplicated sample code

* Drop another style sample

https://github.com/ruby/ruby/pull/2389#issuecomment-522489520

* Update sample list
This commit is contained in:
Kenichi Kamiya 2019-08-19 18:43:23 +09:00 committed by Takashi Kokubun
parent 209ea85b54
commit 8882986d97
4 changed files with 1 additions and 28 deletions

View file

@ -16,7 +16,6 @@ fib.pl Fibonacci number (Perl)
fib.py Fibonacci number (Python)
fib.rb Fibonacci number (Ruby)
fib.scm Fibonacci number (Scheme)
freq.rb count word occurrence
from.rb scan mail spool
fullpath.rb convert ls -lR to fullpath format
less.rb front end for less
@ -29,7 +28,6 @@ mpart.rb split file int multi part
observ.rb observer design pattern sample
occur.pl count word occurrence (Perl)
occur.rb count word occurrence (Ruby)
occur2.rb count word occurrence - another style
philos.rb famous dining philosophers
pi.rb calculate PI
rcs.awk random character stereogram (AWK)

View file

@ -1,12 +0,0 @@
# word occurrence listing
# usage: ruby freq.rb file..
freq = Hash.new(0)
while line = gets()
line.scan(/\w+/) do |word|
freq[word] += 1
end
end
for word in freq.keys.sort!
print word, " -- ", freq[word], "\n"
end

View file

@ -2,7 +2,7 @@
# usage: ruby occur.rb file..
freq = Hash.new(0)
while line = gets()
for word in line.split(/\W+/)
line.scan(/\w+/) do |word|
freq[word] += 1
end
end

View file

@ -1,13 +0,0 @@
# word occurrence listing
# usage: ruby occur2.rb file..
freq = {}
ARGF.each_line do |line|
for word in line.split(/\W+/)
freq[word] ||= 0
freq[word] += 1
end
end
for word in freq.keys.sort
printf("%s -- %d\n", word, freq[word])
end