summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sample/README2
-rw-r--r--sample/freq.rb12
-rw-r--r--sample/occur.rb2
-rw-r--r--sample/occur2.rb13
4 files changed, 1 insertions, 28 deletions
diff --git a/sample/README b/sample/README
index 796aba1dc3d..b55234a9470 100644
--- a/sample/README
+++ b/sample/README
@@ -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)
diff --git a/sample/freq.rb b/sample/freq.rb
deleted file mode 100644
index 1b2194c69ac..00000000000
--- a/sample/freq.rb
+++ /dev/null
@@ -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
diff --git a/sample/occur.rb b/sample/occur.rb
index 42151d85e81..5927ebc8891 100644
--- a/sample/occur.rb
+++ b/sample/occur.rb
@@ -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
diff --git a/sample/occur2.rb b/sample/occur2.rb
deleted file mode 100644
index ef8ad2c5412..00000000000
--- a/sample/occur2.rb
+++ /dev/null
@@ -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