I'm having some troubles with F# because i'm learning. I have something like the next code:
let A = [| [| [|"1";"Albert"|];[|"2";"Ben"|] |];[| [|"1";"Albert"|];[|"3";"Carl"|] |] |]
(Type A: string[][][])
I'm trying to convert A to:
let B = [| [|"1"; "Albert" |] ; [| "2"; "Ben"|] ; [| "3"; "Carl"|] |]
(Type B: string[][])
I don't know how to do this. I've been trying some for and recursive function but I don't get it.
You could use Array.concat to turn the string[][][] into string[][], and then Seq.distinct to remove the duplicate string arrays.
let b =
[| [| [|"1";"Albert"|];[|"2";"Ben"|] |];[| [|"1";"Albert"|];[|"3";"Carl"|] |] |]
|> Array.concat
|> Seq.distinct
|> Seq.toArray
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With