Union - Simple

Category:
LINQ
Description: This sample uses Union to create one sequence that contains the unique values from both arrays.
Code:
let LINQ04() =
let numbersA = [ 0; 2; 4; 5; 6; 8; 9 ]
let numbersB = [ 1; 3; 5; 7; 8 ]

numbersA.Union(numbersB) |> Seq.iter(fun n -> printfn "%d" n)

//sample output
// 0
// 2
// 4
// 5
// 6
// 8
// 9
// 1
// 3
// 7


Execution Result:
0
2
4
5
6
8
9
1
3
7

Last edited Sep 15, 2011 at 2:31 PM by Jackhu, version 2

Comments

No comments yet.