Challenge Tuples
Salih Dincer
salihdb at hotmail.com
Fri May 3 05:11:28 UTC 2024
On Wednesday, 1 May 2024 at 14:15:19 UTC, Andrey Zherikov wrote:
>
>
> Shorter and without allocations:
> ```d
> import std.typecons : tuple;
> import std.algorithm : sum, each;
>
> auto sum(int i) => i;
>
> void main()
> {
> auto t = tuple(1, 2, 3, [1, 3], 5);
>
> int res=0;
> t.each!(e => res += sum(e));
> assert(res == 15);
> }
> ```
Super!
In summary, D is clearly ahead of the tuple. Especially with its
features similar to AliasSeq, I think it is unrivaled. Wouldn't
it be great if there was a feature that worked at runtime...
SDB at 79
More information about the Digitalmars-d-learn
mailing list