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

Feature Request: Addition of Symmetric Difference Operation for Sets and Arrays #1886

Open
forno opened this issue Jun 15, 2023 · 2 comments

Comments

@forno
Copy link
Contributor

forno commented Jun 15, 2023

🚀 Feature request

Current Behavior

Currently, the library only supports set operations like intersection, union, and difference.

Desired Behavior

In set theory, there are four fundamental operations:

  • intersection
  • union
  • difference
  • symmetric difference

I would like to see support for the symmetric difference operation in this library.

Suggested Solution

Add a symmetricDifference function to the set or array modules, similar to how the difference function is currently implemented.

Who does this impact? Who is this for?

This feature would benefit all users of this library.

Describe alternatives you've considered

N/A

Additional context

I would prefer an implementation optimized for sorted arrays to improve computational complexity.
However, this would require a new Monoid, such as SortedArray or OrderedSet.
This request is related to issue #1843.

Your environment

Software Version(s)
fp-ts 2.16.0
TypeScript 5.1.3
@samhh
Copy link
Contributor

samhh commented Jun 15, 2023

FWIW there's https://samhh.github.io/fp-ts-std/modules/Array.ts.html#symmetricdifference, which goes by input order. It should be possible to make it more efficient.

@forno
Copy link
Contributor Author

forno commented Jun 16, 2023

@samhh Thank you for your information. It works for me.
In the meantime, I will use fp-ts-std as an alternative.

By the way, I believe this function should exist in fp-ts, not just in fp-ts-std.

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

2 participants