Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description text of difference #246

Open
flip111 opened this issue May 26, 2024 · 0 comments
Open

Description text of difference #246

flip111 opened this issue May 26, 2024 · 0 comments

Comments

@flip111
Copy link

flip111 commented May 26, 2024

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].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant