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

Cartesian product with an empty set should be an empty set #339

Open
GrosSacASac opened this issue Apr 15, 2019 · 8 comments
Open

Cartesian product with an empty set should be an empty set #339

GrosSacASac opened this issue Apr 15, 2019 · 8 comments

Comments

@GrosSacASac
Copy link

@GrosSacASac GrosSacASac commented Apr 15, 2019

https://github.com/trekhleb/javascript-algorithms/blob/master/src/algorithms/sets/cartesian-product/cartesianProduct.js#L8

I think it makes more sense to return an empty array

// invalid input return null or throw an error
if (!setA || !setB) {
    return null;
}
if (!setA.length || !setB.length) {
    return []; 
}
// or do nothing since the for loop will not trigger anyway
@mik-laj
Copy link

@mik-laj mik-laj commented Jun 22, 2019

Can you create a PR that will introduce this change?

@GrosSacASac
Copy link
Author

@GrosSacASac GrosSacASac commented Jun 22, 2019

@GrosSacASac
Copy link
Author

@GrosSacASac GrosSacASac commented Oct 1, 2019

could you have a look ?

@Veeloxfire

This comment was marked as resolved.

@blondieblue-eyes
Copy link

@blondieblue-eyes blondieblue-eyes commented Jan 31, 2020

I need to find out how to unlink or unhack every device help

@lazarljubenovic
Copy link

@lazarljubenovic lazarljubenovic commented Jan 31, 2020

You're lost, bud.

@blondieblue-eyes
Copy link

@blondieblue-eyes blondieblue-eyes commented Jan 31, 2020

@blondieblue-eyes
Copy link

@blondieblue-eyes blondieblue-eyes commented Jan 31, 2020

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

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.