Commit a2a0f47
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}>"