Last active
July 27, 2016 23:57
-
-
Save oddlyfunctional/1bb2b13c03ad08f10bdfddc40dbd887e to your computer and use it in GitHub Desktop.
Find adjectives in standard UNIX dictionary of words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
words_path = [ | |
'/usr/share/dict/words' | |
'/usr/dict/words' | |
].find { |path| File.exists?(path) } | |
fail "Couldn't find words file in the system" unless words_path | |
# I’m using each_line so we don’t load everything | |
# into memory at once, since the file is huge. | |
awesome_adjectives = File.open(words_path, 'r') | |
.each_line | |
.select { |line| line =~ /^[a-z].*ly$/ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment