Re: static array is not a range

2024-01-10 Thread Siarhei Siamashka via Digitalmars-d-learn
On Tuesday, 9 January 2024 at 21:30:06 UTC, Alexibu wrote: If each works, I can't see why map filter etc can't work consistently where they only need an input range. ```d auto line = arr.filter!(a > 0).map!(a => a.to!string).joiner("\t").text; ``` Should be fine because each result range is pa

Re: static array is not a range

2024-01-09 Thread Alexibu via Digitalmars-d-learn
On Tuesday, 9 January 2024 at 13:22:24 UTC, bachmeier wrote: On Tuesday, 9 January 2024 at 10:11:35 UTC, Alexibu wrote: It looks like isInputRange is false for arrays with fixed length by design. I can do: ```d float[4] arr; foreach(x;arr) writefln("%s",x) ``` but not : ```d arr.each!(a =

Re: static array is not a range

2024-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 9, 2024 6:22:24 AM MST bachmeier via Digitalmars-d-learn wrote: > On Tuesday, 9 January 2024 at 10:11:35 UTC, Alexibu wrote: > > It looks like isInputRange is false for arrays with fixed > > length by design. > > > > I can do: > > > > ```d > > float[4] arr; > > foreach(x;arr) >

Re: static array is not a range

2024-01-09 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 9 January 2024 at 10:11:35 UTC, Alexibu wrote: It looks like isInputRange is false for arrays with fixed length by design. I can do: ```d float[4] arr; foreach(x;arr) writefln("%s",x) ``` but not : ```d arr.each!(a => a.writefln("%s",a)); ``` Is there a good reason for this ? I

Re: static array is not a range

2024-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 9, 2024 4:13:23 AM MST Alexibu via Digitalmars-d-learn wrote: > On Tuesday, 9 January 2024 at 10:44:34 UTC, Jonathan M Davis > > wrote: > > How would it even be possible for a static array to be a range? > > It has a fixed length. For a type to work as a range, it needs > > to

Re: static array is not a range

2024-01-09 Thread Alexibu via Digitalmars-d-learn
On Tuesday, 9 January 2024 at 10:44:34 UTC, Jonathan M Davis wrote: How would it even be possible for a static array to be a range? It has a fixed length. For a type to work as a range, it needs to be possible to pop elements off of it, which you can't do with a static array. Input ranges must

Re: static array is not a range

2024-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 9, 2024 3:11:35 AM MST Alexibu via Digitalmars-d-learn wrote: > It looks like isInputRange is false for arrays with fixed length > by design. > > I can do: > > ```d > float[4] arr; > foreach(x;arr) > writefln("%s",x) > ``` > but not : > > ```d > arr.each!(a => a.writefln("%