def dropWhile[A](l: List[A], f: A => Boolean): List[A] =
l match {
case Cons(h, t) if f(h) => dropWhile(t, f)
case _ => l
}
dropWhile(Nil, (x: Int) => x > 0)
Assuming the following code is available for your reference
sealed trait List[+A]
case object Nil extends List[Nothing]
case class Cons[+A](head: A, tail: List[A]) extends List[A]
Login in to like
Login in to comment