lo icon indicating copy to clipboard operation
lo copied to clipboard

Undefined behaviors on duplicate values in collections

Open muhac opened this issue 2 years ago • 1 comments

https://github.com/samber/lo/blob/75ed9bb40ff4ec3d50adf5d8a5e34644ab492516/intersect.go#L48

In:  Intersect[int]([]int{0, 6, 0}, []int{0, 1, 2, 3, 5, 5, 6, 6})
Out: []int{0, 6, 6}

In:  Difference[int]([]int{0, 1, 2, 3, 3, 4, 4}, []int{0, 1, 2, 2, 3, 5, 5})
Out: []int{4, 4}, []int{5, 5}

In:  Union[int]([]int{0, 1, 2, 3, 3, 5, 6, 6}, []int{0, 1, 2, 4, 4, 5, 5, 6})
Out: []int{0, 1, 2, 3, 3, 5, 6, 6, 4, 4}

Hello, these functions are dealing with duplicate values differently. Is there a rule that the collections disallow duplicates?

muhac avatar Apr 24 '22 07:04 muhac

Related to #45

wirekang avatar Apr 30 '22 10:04 wirekang