From bfc7c25bda04697463a36b9eb278e00407895a53 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 4 Nov 2013 11:30:14 +0100 Subject: Fallback to old treatement of tuples. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For interoperability we will keep for the time being the traditional treatment of tuples as instances of Tuple 2… Tuple 22. The new hlist-like treatment will be done in a future step. The flip is controlled by variable "unboxedPairs". --- tests/pos/Coder.scala | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/pos/Coder.scala (limited to 'tests/pos/Coder.scala') diff --git a/tests/pos/Coder.scala b/tests/pos/Coder.scala new file mode 100644 index 000000000..62ceebe80 --- /dev/null +++ b/tests/pos/Coder.scala @@ -0,0 +1,41 @@ +import collection.mutable.HashMap + +class Coder(words: List[String]) { + + (2 -> "ABC", new ArrowAssoc('3') -> "DEF") + + private val mnemonics = Map( + '2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL", + '6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ") + + /** Invert the mnemonics map to give a map from chars 'A' ... 'Z' to '2' ... '9' */ + private val charCode: Map[Char, Char] = mnemonics flatMap { ds => + val digit = ds._1 + val str = ds._2 + str map (ltr => ltr -> digit) + } + +// for ((digit, str) <- mnemonics; ltr <- str) yield ltr -> digit + + /** Maps a word to the digit string it can represent */ + private def wordCode(word: String): String = ??? + + /** A map from digit strings to the words that represent them */ + private val wordsForNum: Map[String, List[String]] = ??? + + /** All ways to encode a number as a list of words */ + def encode(number: String): Set[List[String]] = ??? + + /** Maps a number to a list of all word phrases that can represent it */ + def translate(number: String): Set[String] = encode(number) map (_ mkString " ") + +} +/* +/** Test code */ +object Coder { + def main(args : Array[String]) : Unit = { + val coder = new Coder(List("Scala", "sobls", "Python", "Ruby", "C", "A", "rocks", "sucks", "works", "Racka")) +// println(coder.wordsForNum) + println(coder.translate("7225276257")) + } +}*/ -- cgit v1.2.3