Commit a2a0f47

bryon <bryon@RDA23715CL>
2014-01-22 14:40:44
add faster include
1 parent 056c2fa
Changed files (1)
level0
@@ -5,12 +5,18 @@
 # will automatically download this dictionary for you if you don't
 # have it already.
 
+class Array
+  def faster_include?(n)
+    !(self & [n]).empty?
+  end
+end
+
 path = ARGV.length > 0 ? ARGV[0] : '/usr/share/dict/words'
 entries = File.read(path).split("\n")
 
 contents = $stdin.read
 output = contents.gsub(/[^ \n]+/) do |word|
-  if entries.include?(word.downcase)
+  if entries.faster_include?(word.downcase)
     word
   else
     "<#{word}>"