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

Fix powerset #51

Merged
merged 4 commits into from
Sep 28, 2020
Merged

Fix powerset #51

merged 4 commits into from
Sep 28, 2020

Conversation

jankapunkt
Copy link
Owner

@jankapunkt jankapunkt commented Sep 17, 2020

Summary

Power set method has been fixed, also fixed has/add function when Sets are involved. See #50

Behavior

You can either run babel or node (while with node you need to require('./dist/index.js') and enter the following:

``javascript

Set.power(new Set([1, 2, 3]))
Set {
Set { 2, 3 },
Set { 3 },
Set {},
Set { 2 },
Set { 1, 3 },
Set { 1 },
Set { 1, 2 },
Set { 1, 2, 3 } }


or

```javascript
> Set.power(new Set([1, 2, 3, 4 ]))
Set {
  Set { 2, 3, 4 },
  Set { 3, 4 },
  Set { 4 },
  Set {},
  Set { 3 },
  Set { 2, 4 },
  Set { 2 },
  Set { 2, 3 },
  Set { 1, 3, 4 },
  Set { 1, 4 },
  Set { 1 },
  Set { 1, 3 },
  Set { 1, 2, 4 },
  Set { 1, 2 },
  Set { 1, 2, 3 },
  Set { 1, 2, 3, 4 } }

it should also work for sets of sets (according to the tests).

Notes:

One recursion removed and replaced with iteration (should increase perf).

Copy link
Collaborator

@michaelmior michaelmior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really follow what the problem was, but I can confirm that these changes fix things for me :)

@jankapunkt jankapunkt merged commit a1e7ca4 into master Sep 28, 2020
@jankapunkt
Copy link
Owner Author

@michaelmior fix published in v1.4.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

Successfully merging this pull request may close these issues.

None yet

2 participants