Jason Miesionczek
Jason Miesionczek

Reputation: 14448

Transform List of Tuple Lists into single list of tuples

I have a large list that looks essentially like this:

let someList = [ [(1,2);(2,3);etc]; [(1,2);(2,3);etc]; etc]

a list that contains lists, that contain tuples. what is the best way to reduce that into a single list of all the tuples?

Upvotes: 1

Views: 398

Answers (2)

Stephen Swensen
Stephen Swensen

Reputation: 22297

There's a built-in function for this, List.concat

[[(1,2); (3,4)]; [(5,6); (7,8)] ] |> List.concat

Upvotes: 10

desco
desco

Reputation: 16782

let l = [[(1,2); (3,4)]; [(5,6); (7,8)] ]
let flattened = List.collect id l // [(1, 2); (3, 4); (5, 6); (7, 8)]

Upvotes: 1

Related Questions