summaryrefslogtreecommitdiff
path: root/sample/occur.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/occur.rb')
-rw-r--r--sample/occur.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/sample/occur.rb b/sample/occur.rb
new file mode 100644
index 0000000..12e469d
--- /dev/null
+++ b/sample/occur.rb
@@ -0,0 +1,10 @@
+freq = {}
+while gets()
+ for word in $_.split(/\W+/)
+ freq[word] +=1
+ end
+end
+
+for word in freq.keys.sort
+ printf("%s -- %d\n", word, freq[word])
+end