ОФП 1 лаба (12)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
val list = List(0,1,-1, -2,314,-342,5253)
val partition: (List[Int], Int =>Boolean) =>(List[Int],List[Int]) = {
case (Nil, p) => (Nil, Nil)
case (x :: xs, p) if(p(x)) => {
val (fst, scd) = partition(xs,p)
(x :: fst, scd)
}
case (x :: xs, p) => {
val (fst, scd) = partition(xs,p)
(fst, x :: scd)
}
}
val s = partition (list, _>0)