Skip to content

Instantly share code, notes, and snippets.

@theon
Last active August 29, 2015 14:26
Show Gist options
  • Save theon/cc559c6533df4e278be8 to your computer and use it in GitHub Desktop.
Save theon/cc559c6533df4e278be8 to your computer and use it in GitHub Desktop.
import scala.io.Source
val reverseLetters = ( ('a' to 'z') zip ('a' to 'z').reverse ).toMap.withDefault(identity)
val words = Source.fromFile("/usr/share/dict/words").getLines.toVector
def isWordMatch(word: String) = {
val reverseLetterWord = word.toLowerCase.map(reverseLetters)
reverseLetterWord.reverse == word
}
println(words filter isWordMatch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment