How to convert (int* int) list to (int: list) in F#

N.T.C

I have a sequence pairwise like: Original = [(0,0); (1,2); (3,4)] I would like to convert this seq of (int *int) to a seq of int Final= [0,0,1,2,3,4] Can anyone please suggest me the way to do this ?

Gus

Use List.collect

[(0,0); (1,2); (3,4)] |> List.collect (fun (x,y) -> [x; y])

In your question you say you want a List at the beginning but at the end you say Sequence, anyway for sequences collect is also available.

For more information collect is the monadic function bind or the operator >>= in some languages (SelectMany in C#) which for lists/sequences is equivalent to a map followed by a concat.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related