Re: Why does sum not work in static arrays?

2020-10-11 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Oct 11, 2020 at 01:26:13PM +, Alaindevos via Digitalmars-d-learn wrote: > Sidenote, sort also not works with static arrays. Just slice it with []. T -- I think the conspiracy theorists are out to get us...

Re: Why does sum not work in static arrays?

2020-10-11 Thread Alaindevos via Digitalmars-d-learn
Sidenote, sort also not works with static arrays.

Re: Why does sum not work in static arrays?

2020-10-10 Thread mw via Digitalmars-d-learn
On Sunday, 6 December 2015 at 12:27:49 UTC, cym13 wrote: On Sunday, 6 December 2015 at 12:23:05 UTC, Tim K. wrote: Hi! I have the following code: int main(string[] argv) { import std.algorithm: sum; import std.stdio: writeln; uint[3] a1 = [1, 2, 3]; uint

Re: Why does sum not work in static arrays?

2015-12-06 Thread Tim K. via Digitalmars-d-learn
On Sunday, 6 December 2015 at 12:27:49 UTC, cym13 wrote: A static array is a value type so it is passed by value to functions. Oh, right, I totally forgot about that. Thank you for reminding me. And yes, I was not planning on doing that. I just have a local fixed-size array that I wanted to g

Re: Why does sum not work in static arrays?

2015-12-06 Thread cym13 via Digitalmars-d-learn
On Sunday, 6 December 2015 at 12:23:05 UTC, Tim K. wrote: Hi! I have the following code: int main(string[] argv) { import std.algorithm: sum; import std.stdio: writeln; uint[3] a1 = [1, 2, 3]; uint[] a2; for (int i = 1; i <= 3; ++i) a2

Re: Why does sum not work in static arrays?

2015-12-06 Thread drug via Digitalmars-d-learn
06.12.2015 15:23, Tim K. пишет: Hi! I have the following code: int main(string[] argv) { import std.algorithm: sum; import std.stdio: writeln; uint[3] a1 = [1, 2, 3]; uint[] a2; for (int i = 1; i <= 3; ++i) a2 ~= i; w

Why does sum not work in static arrays?

2015-12-06 Thread Tim K. via Digitalmars-d-learn
Hi! I have the following code: int main(string[] argv) { import std.algorithm: sum; import std.stdio: writeln; uint[3] a1 = [1, 2, 3]; uint[] a2; for (int i = 1; i <= 3; ++i) a2 ~= i; writeln("a1: ", sum(a1)); writeln("