object HelloWorld { def main(args: Array[String]) { def pow[T](l: Vector[T], w: T => Boolean): Vector[T] = l.reverse.filterNot(w) val z1 = pow[Int](Vector(0, 1, 1, 2), num => {if(num%2 != 0) true else false}) z1.foreach(println) println val z2 = pow[Char](Vector('a','b','c','d'), let => {if(let=='b')true else false}) z2.foreach(println)} def frq(l: String) : Map[Char, Int] = { l.groupBy(identity).mapValues(_.size) } println(frq("Abba")) }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more