summaryrefslogtreecommitdiff
path: root/sample/freq.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/freq.rb')
-rw-r--r--sample/freq.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/sample/freq.rb b/sample/freq.rb
new file mode 100644
index 0000000..7417e0b
--- /dev/null
+++ b/sample/freq.rb
@@ -0,0 +1,13 @@
+#
+
+freq = {}
+while gets()
+ while sub(/\w+/, '')
+ word = $&
+ freq[word] +=1
+ end
+end
+
+for word in freq.keys.sort
+ printf("%s -- %d\n", word, freq[word])
+end