File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -15,14 +15,16 @@ class Coder(words: List[String]) {
1515 }
1616
1717 /** Invert the mnemonics map to give a map from chars 'A' ... 'Z' to '2' ... '9' */
18- private val charCode0 : Map [Char , Char ] = mnemonics withFilter {
19- case (digit, str) => true
20- case _ => false
21- } flatMap { x$1 =>
22- x$1 match {
23- case (digit, str) => str map (ltr => ltr -> digit)
18+ private val charCode0 : Map [Char , Char ] = mnemonics
19+ .withFilter {
20+ case (digit, str) => true
21+ case _ => false
22+ }
23+ .flatMap { x$1 =>
24+ x$1 match {
25+ case (digit, str) => str map (ltr => ltr -> digit)
26+ }
2427 }
25- }
2628
2729 private val charCode : Map [Char , Char ] =
2830 for ((digit, str) <- mnemonics; ltr <- str) yield ltr -> digit
@@ -42,12 +44,12 @@ class Coder(words: List[String]) {
4244 splitPoint <- 1 to number.length
4345 word <- wordsForNum(number take splitPoint)
4446 rest <- encode(number drop splitPoint)
45- } yield word :: rest
47+ }
48+ yield word :: rest
4649 }.toSet
4750
4851 /** Maps a number to a list of all word phrases that can represent it */
4952 def translate (number : String ): Set [String ] = encode(number) map (_ mkString " " )
50-
5153}
5254
5355object Coder {
You can’t perform that action at this time.
0 commit comments