purescript-arrays
purescript-arrays copied to clipboard
Description text of `difference`
Example:
difference [2, 1, 2] [2, 2, 3] == [1]
https://pursuit.purescript.org/packages/purescript-arrays/7.3.0/docs/Data.Array#v:difference
Delete the first occurrence of each element in the second array from the first array, creating a new array.
I read the description as follows:
- each element in the second array: 2, 2, 3
- first occurrence of each element in the second array: 2, 3
- delete [2,3] from the first array: [2,1,2] ---> deleting [2,3] ---> [1,2]
This would be a clearer description of what this function does:
For each element in the second array, find an occurrence from left to right in the first array and remove it when found.
I think the word "first" should be avoided, because in the example above then second 2
from [2,2,3]
is matched against the second 2
from [2,1,2]
.