I want to find all items before and equal the first 7:
7
val list = List(1,4,5,2,3,5,5,7,8,9,2,7,4)
My solution is:
Possible way of doing this:
def takeUntil[A](list:List[A])(predicate: A => Boolean):List[A] = if(list.isEmpty) Nil else if(predicate(list.head)) list.head::takeUntil(list.tail)(predicate) else List(list.head)