Challenge Tuples
Salih Dincer
salihdb at hotmail.com
Sat Apr 27 17:38:13 UTC 2024
On Saturday, 27 April 2024 at 15:36:40 UTC, Nick Treleaven wrote:
> On Saturday, 27 April 2024 at 15:32:40 UTC, Nick Treleaven
> wrote:
>> On Saturday, 27 April 2024 at 11:55:58 UTC, Basile B. wrote:
>>> foreach const e in u do
>>> if echo(is, e, T) do
>>> result += e;
>
>> static if (is(typeof(e) == int))
>> r += e;
>
> Actually I would write that:
> ```d
> R r;
> foreach (e; v)
> {
> static if (is(typeof(e) : R))
> ```
I like the new sum() function, great Nick! Moreover, it also
works with an ordinary range:
```d
enum limit = 100; // sum = 5050
iota(limit + 1).sum.writeln;
```
Python seems too complicated to me, but C# looks delicious.
Moreover, it was implemented without defining IEnumerator. Well
done Matheus!
SDB at 79
More information about the Digitalmars-d-learn
mailing list