You are viewing a single comment's thread. Return to all comments →
Scala : Create Either Single-Element List Or Empty List for each element based on condition and flatMap to merge them.
def f(delim:Int,arr:List[Int]):List[Int] = arr.flatMap(x=>if (x<delim) List(x) else List())
Filter Array
You are viewing a single comment's thread. Return to all comments →
Scala : Create Either Single-Element List Or Empty List for each element based on condition and flatMap to merge them.