object Test {
def main(args: Array[String]) {
// val xs = 3 :: 6 :: 12 :: Nil
// val s =xs match {
// case List(a, b) => a * b
// case List(a, b, c) => a + b + c
// case _ => 0
// }
// val st = “a b c”
// val s=TestOption(st) match {
// case Some(st)=> s”Good morning, $st!”
// case _ => “Welcome! Please make sure to fill in your name!”
// }
// val wordFrequencies = (“habitual”, 6) :: (“and”, 56) :: (“consuetudinary”, 2) ::
// (“additionally”, 27) :: (“homely”, 5) :: (“society”, 13) :: Nil
// print(wordsWithoutOutliers(wordFrequencies))
//
// val wordFrequencies = (“habitual”, 6) :: (“and”, 56) :: (“consuetudinary”, 2) ::
// (“additionally”, 27) :: (“homely”, 5) :: (“society”, 13) :: Nil
// val pf: PartialFunction[(String, Int), String] = {
// case (word, freq) if freq > 3 && freq < 25 => word
// }
// print(wordFrequencies.collect(pf))
}
def TestOption(name: String): Option[Seq[String]] = {
val names = name.trim.split(” “)
if (names.forall(_.isEmpty)) None
else Some(names)
}
def wordsWithoutOutliers(wordFrequencies: Seq[(String, Int)]): Seq[String] =
wordFrequencies.filter { case (, f) => f > 3 && f < 25 }.map { case (w, ) => w }
}