How can I remove duplicates in an F# sequence without using references

前端 未结 6 408
南方客
南方客 2021-01-20 09:07

I have a sorted sequence and want to go through it and return the unique entries in the sequence. I can do it using the following function, but it uses reference variables a

6条回答
  •  无人共我
    2021-01-20 09:54

    Just initialize a unique collection (like a set) with the sequence like this:

    set [1; 2; 3; 3; 4; 5; 5];;
    => val it : Set = set [1; 2; 3; 4; 5]
    

提交回复
热议问题