[Issue 13104] std.typecons.tupleOp

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 31 14:10:26 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=13104

Seb <greensunny12 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |greensunny12 at gmail.com

--- Comment #1 from Seb <greensunny12 at gmail.com> ---

Have a look at https://github.com/dlang/phobos/pull/6386

with this the following will work:



(tuple(1, 2) ~ tuple(3, 4)).expand.only.sum = 10
(tuple(1, 2) ~ tuple(3, 4)).expand.only.max = 4


> tupleOp2!q{a + b}(tuple(1, 1.5), tuple(2, 3.2))

So here's what we got today:

zip(tuple(1, 1.5).expand.only, tuple(2, 3.2).expand.only).map!(a => a[0] +
a[1]).writeln;

https://run.dlang.io/is/6rq9MB

What I think could be improved:

- make tuples ranges by default (no .expand.only hacks)
- allow map to take a multi-argument lambda if the size of the front's element
is statically known

--


More information about the Digitalmars-d-bugs mailing list