Thread overview
[Issue 6718] "nWayUnion" => "nWayMerge", plus true nWayUnion
Jul 13
RazvanN
5 days ago
RazvanN
5 days ago
RazvanN
5 days ago
RazvanN
October 14
https://issues.dlang.org/show_bug.cgi?id=6718

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |bootcamp

--- Comment #7 from Andrei Alexandrescu <andrei@erdani.com> ---
nWayUnion shall stay, but we can add new and better names and alias nWayUnion to one of them.

--
July 13
https://issues.dlang.org/show_bug.cgi?id=6718

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #8 from RazvanN <razvan.nitu1305@gmail.com> ---
So, how should we proceed here? Rename nWayUnion to nWayMerge and alias nWayUnion to it? If we do that we should probably deprecate nWayUnion.

--
6 days ago
https://issues.dlang.org/show_bug.cgi?id=6718

--- Comment #9 from Andrei Alexandrescu <andrei@erdani.com> ---
(In reply to RazvanN from comment #8)
> So, how should we proceed here? Rename nWayUnion to nWayMerge and alias nWayUnion to it? If we do that we should probably deprecate nWayUnion.

@RazvanN, let's do this:

* rename nWayUnion to multiwayMerge

* rename struct NWayUnion to MultiwayMerge

* leave nWayUnion as an undocumented alias of multiwayMerge. Mention in the documentation that "...for backward compatibility, `multiwayMerge` is also available under the name `nWayUnion`, which will be deprecated. New code should use `multiwayMerge`." Coordinate with Sebastian and Vladimir about the exact text and layout.

That would be one PR. The second PR:

* add function multiwayUnion that actually performs the union (no repeats). A simple implementation is to pipe the result of multiwayMerge through uniq.

* add function multiwayIntersection that performs the intersection of multiple sets.

These pull requests would close this issue.

--
5 days ago
https://issues.dlang.org/show_bug.cgi?id=6718

--- Comment #10 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to Andrei Alexandrescu from comment #9)
> (In reply to RazvanN from comment #8)
> > So, how should we proceed here? Rename nWayUnion to nWayMerge and alias nWayUnion to it? If we do that we should probably deprecate nWayUnion.
> 
> @RazvanN, let's do this:
> 
> * rename nWayUnion to multiwayMerge
> 
> * rename struct NWayUnion to MultiwayMerge
> 
> * leave nWayUnion as an undocumented alias of multiwayMerge. Mention in the documentation that "...for backward compatibility, `multiwayMerge` is also available under the name `nWayUnion`, which will be deprecated. New code should use `multiwayMerge`." Coordinate with Sebastian and Vladimir about the exact text and layout.
> 
> That would be one PR. The second PR:
> 
> * add function multiwayUnion that actually performs the union (no repeats). A simple implementation is to pipe the result of multiwayMerge through uniq.
> 
> * add function multiwayIntersection that performs the intersection of multiple sets.
> 
> These pull requests would close this issue.

We already have setIntersection which, as bearophile pointed out, computes the bags intersection. Maybe we should also rename setIntersection to multiwayIntersection and use setIntersection for the newly added function. I know that this may break code but setIntersection is very misleading

--
5 days ago
https://issues.dlang.org/show_bug.cgi?id=6718

--- Comment #11 from Andrei Alexandrescu <andrei@erdani.com> ---
>Maybe we should also rename setIntersection to multiwayIntersection

setIntersection has two inputs. "multiwayIntersection" would have multiple inputs (a range of ranges) and would be a distinct function with important uses and its own theory and practice (http://www.cs.toronto.edu/~tl/papers/wea06.pdf is a good overview).

--
5 days ago
https://issues.dlang.org/show_bug.cgi?id=6718

--- Comment #12 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to Andrei Alexandrescu from comment #11)
> >Maybe we should also rename setIntersection to multiwayIntersection
> 
> setIntersection has two inputs. "multiwayIntersection" would have multiple inputs (a range of ranges) and would be a distinct function with important uses and its own theory and practice (http://www.cs.toronto.edu/~tl/papers/wea06.pdf is a good overview).

If I understand correctly, setIntersection is going to do a bags intersection for just 2 ranges, while multiwayIntersection is going to be a generalization of set intersection (i.e. it will still do bags intersection)

--
5 days ago
https://issues.dlang.org/show_bug.cgi?id=6718

--- Comment #13 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to Andrei Alexandrescu from comment #11)
> >Maybe we should also rename setIntersection to multiwayIntersection
> 
> setIntersection has two inputs. "multiwayIntersection" would have multiple inputs (a range of ranges) and would be a distinct function with important uses and its own theory and practice (http://www.cs.toronto.edu/~tl/papers/wea06.pdf is a good overview).

Actually, looking at the implementation, it seems that setIntersection also has a variable number of inputs : https://dlang.org/phobos/std_algorithm_setops.html#setIntersection

--
5 days ago
https://issues.dlang.org/show_bug.cgi?id=6718

--- Comment #14 from Andrei Alexandrescu <andrei@erdani.com> ---
(In reply to RazvanN from comment #13)
> (In reply to Andrei Alexandrescu from comment #11)
> > >Maybe we should also rename setIntersection to multiwayIntersection
> > 
> > setIntersection has two inputs. "multiwayIntersection" would have multiple inputs (a range of ranges) and would be a distinct function with important uses and its own theory and practice (http://www.cs.toronto.edu/~tl/papers/wea06.pdf is a good overview).
> 
> Actually, looking at the implementation, it seems that setIntersection also has a variable number of inputs : https://dlang.org/phobos/std_algorithm_setops.html#setIntersection

It has a number of inputs known during compilation. True "multi" set intersection takes a range of ranges, i.e. an arbitrary number of sets.

--
5 days ago
https://issues.dlang.org/show_bug.cgi?id=6718

--- Comment #15 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/9efa504bdca2b2644375e86d3b1527170512b726 Fix Issue 6718 - nWayUnion => nWayMerge, plus true nWayUnion

https://github.com/dlang/phobos/commit/bdae5f08f3cf4ed153063ad1d9a07fbb5aa12668 Merge pull request #5620 from RazvanN7/Issue_6718

[WIP] Fix Issue 6718 - nWayUnion => nWayMerge, plus true nWayUnion merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>

--