You are viewing a single comment's thread. Return to all comments →
Some experimenting with currying (I don't know what im doing)
def f(delim: Int, arr: List[Int]): List[Int] = { def myFilter(func: Int => Boolean, arr: List[Int]): List[Int] => List[Int] = { if (arr.isEmpty) (x: List[Int]) => x else if (func(arr.head)) (x: List[Int]) => myFilter(func, arr.tail)(x.:+(arr.head)) else (x: List[Int]) => myFilter(func, arr.tail)(x) } val aFunc: Int => Boolean = x => x < delim myFilter(aFunc, arr)(List()) }
Seems like cookies are disabled on this browser, please enable them to open this website
Filter Array
You are viewing a single comment's thread. Return to all comments →
Some experimenting with currying (I don't know what im doing)