Two-dimensional slices in D

Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 14 14:57:35 PDT 2015


On Tuesday, 14 April 2015 at 15:16:10 UTC, Ivan Kazmenko wrote:
> On Tuesday, 14 April 2015 at 14:21:41 UTC, Dennis Ritchie wrote:
>> 	writefln("[%([%(%s, %)]%|\n %)]", [a[4][4 .. $], a[5][4 .. 
>> $], a[6][4 .. $], a[7][4 .. $]]);
> At least this can be done as
> -----
> writefln("[%([%(%s, %)]%|\n %)]", a[4..8].map !(b => b[4 .. 
> $]));
> -----

Thanks.

On Tuesday, 14 April 2015 at 17:27:15 UTC, Ali Çehreli wrote:
> On 04/14/2015 07:21 AM, Dennis Ritchie wrote:
>
>> F#:
>> -----
>> printfn "%A" xs.[4 .. 7, 4 .. 9]
>> -----
>
> D supports that syntax as well:
>
>   http://dlang.org/operatoroverloading.html#slice
>
> I have a simple example here:
>
>
> http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.multi-dimensional%20operator%20overloading
>
> Ali

Yes, now I understand. Thanks.


More information about the Digitalmars-d-learn mailing list