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

Comments

@andyferris
Copy link
Contributor

commented Jun 21, 2018

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

This comment has been minimized.

Copy link
Member

commented Jun 21, 2018

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

@andyferris

This comment has been minimized.

Copy link
Contributor Author

commented Jun 21, 2018

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

This comment has been minimized.

Copy link
Member

commented Jun 21, 2018

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

@fredrikekre

This comment has been minimized.

Copy link
Member

commented Mar 5, 2019

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

fredrikekre added a commit that referenced this issue Mar 29, 2019
@mbauman mbauman closed this 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
Projects
None yet
3 participants
You can’t perform that action at this time.