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

mapreduce with multiple input containers #27704

Closed
andyferris opened this issue Jun 21, 2018 · 4 comments
Closed

mapreduce with multiple input containers #27704

andyferris opened this issue Jun 21, 2018 · 4 comments

Comments

@andyferris
Copy link
Member

It occurs to me that it would be great if operations like mapreduce(f, op, a, b) actually worked where a and b are two containers of the same length, like it does for map.

For me, there are two issues here.

  • There is no varargs form for mapreduce that applies zip to the inputs and the appropriate form.
  • Perhaps this is just my taste, but I honestly find the placement of the optional v0 term is a little annoying in mapreduce(f, op, v0, a). If it is optional, maybe it should be an optional argument or a keyword argument. And it can't be an optional (positional) argument when the last term is a varargs list of the input containers.

My suggestion would be a signature something like mapreduce(f, op, a...; v0 = nothing) (we might need something other than nothing, since it seems to mean something these days). Moving v0 would be necessary to have the v0-less mapreduce algorithm with two or more input containers (since it can't magically infer whether the 3rd argument is meant to be v0 or a container to reduce over).

xref: #27677 (comment) cc: @StefanKarpinski

@StefanKarpinski
Copy link
Sponsor Member

Agree that v0 should be a keyword; v0 is not the best name, however, perhaps initial or first?

@andyferris
Copy link
Member Author

Changing v0 in mapreduce would probably mean we should change v0 in reduce...

initial seems OK, I think. R uses init. Python uses initializer. C++ uses init. Haskell documenation refers to "initial value". Rust used init. OTOH, LINQ uses seed but not sure I love it.

We could save 3 letters and go with init.

@StefanKarpinski
Copy link
Sponsor Member

init seems good to me and fairly widely used it seems. seed is terrible.

@fredrikekre
Copy link
Member

This should be implementable now since init is a kwarg, right? Would be nice to have.

@mbauman mbauman closed this as completed in 48fd53d Apr 3, 2019
mbauman added a commit that referenced this issue Apr 3, 2019
Implement vararg methods for mapreduce similar to map, fixes #27704.
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

3 participants