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

fixes #349: add _.partition function #1430

Merged
merged 2 commits into from
Jan 31, 2014
Merged

fixes #349: add _.partition function #1430

merged 2 commits into from
Jan 31, 2014

Conversation

michaelficarra
Copy link
Collaborator

Fixes #349.

jashkenas added a commit that referenced this pull request Jan 31, 2014
fixes #349: add _.partition function
@jashkenas jashkenas merged commit 407d027 into master Jan 31, 2014
@jashkenas
Copy link
Owner

This one is really borderline because it's so close to the simplest use case for reduce ... but, alright.

@@ -843,6 +844,17 @@ <h2 id="arrays">Array Functions</h2>
=&gt; [2, 3, 4]
</pre>

<p id="partition">
<b class="header">partition</b><code>_.partition(array, predicate)</code>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it okay to use "predicate" now? The documentation doesn't currently use this term, though it should: "iterator" is both vague and slightly misleading.

I'd like to open a pull request to replace "iterator" with "predicate" where appropriate (in the code as well as the documentation). Would such a pull request be considered?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I just used what was natural to me. I'd +1 such a PR.

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, that would be a great change.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ghost
Copy link

ghost commented Jan 31, 2014

This looks very similar to _.groupBy and has less features than the underscore-contrib version of _.partition

@michaelficarra
Copy link
Collaborator Author

@Dw40: The underscore-contrib function named partition has nothing to do with this function. The underscore-contrib partition is more like the proposed (and, in my opinion, better named) groupsOf.

@ghost
Copy link

ghost commented Jan 31, 2014

It's still conflicting with a companion project. The way Underscore's _.partition is now doesn't hold a lot of value over what can be achieved by:

_.groupBy([0, 1, 2, 3, 4, 5], isOdd);
// { 'false': [0, 2, 4], 'true': [1, 3, 5] }

@bjmiller
Copy link

bjmiller commented Feb 1, 2014

Why not change the function name in contrib, then? I suspect that Fogus would be OK with that.

@ghost
Copy link

ghost commented Feb 1, 2014

I'm not sure there is enough to differentiate it from _.groupBy. As Jeremy said _.partition was borderline because it was so close to _.reduce, but it's even closer to _.groupBy.

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.

include partition in the core library
5 participants