File tree 1 file changed +11
-9
lines changed 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]) {
15
15
}
16
16
17
17
/** 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
+ }
24
27
}
25
- }
26
28
27
29
private val charCode : Map [Char , Char ] =
28
30
for ((digit, str) <- mnemonics; ltr <- str) yield ltr -> digit
@@ -42,12 +44,12 @@ class Coder(words: List[String]) {
42
44
splitPoint <- 1 to number.length
43
45
word <- wordsForNum(number take splitPoint)
44
46
rest <- encode(number drop splitPoint)
45
- } yield word :: rest
47
+ }
48
+ yield word :: rest
46
49
}.toSet
47
50
48
51
/** Maps a number to a list of all word phrases that can represent it */
49
52
def translate (number : String ): Set [String ] = encode(number) map (_ mkString " " )
50
-
51
53
}
52
54
53
55
object Coder {
You can’t perform that action at this time.
0 commit comments