Pipeline of functions scala

Viewed 2580

Is it possible to create a pipeline of functions in scala?. I wanted to do something like the following syntax in F#, achieved through the |> operator

indexPairs |> Seq.iter (fun (i,j) -> parents.[j] <- Some nodes.[i])

I know this can be easily done with a list comprehension, but the idea is to do more complex things like

indexPairs |> Seq.groupBy fst |> Seq.iter (fun (i, pairs) -> sons.[i] <- pairs |> Seq.map (fun (_,j) -> nodes.[j]) |> Seq.toList)

which helps to better readable code in my opinion.

3 Answers
Related