f# - How do you extract distinct elements from a list? -
i'm pretty new f# , i'm having hard time trying extract list of distinct values list:
let mylist = [ 1; 2; 2; 3; 4; 3 ] // desired list [ 1; 2; 3; 4 ] how do that? see seq has distinct method, not lists.
let mylist = [ 1; 2; 2; 3; 4; 3 ] let distinctlist = mylist |> seq.distinct |> list.ofseq result:
> val mylist : int list = [1; 2; 2; 3; 4; 3] val distinctlist : int list = [1; 2; 3; 4] next f# version (4.0) have list.distinct function
Comments
Post a Comment