Thread overview | |||||
---|---|---|---|---|---|
|
February 18, 2016 ndslice help | ||||
---|---|---|---|---|
| ||||
Hi, I'm trying to generate the following sequences with ndslice. 0 0 0 1 1 1 1 1 1 0 0 0 0 1 2 0 1 2 2 1 0 2 1 0 It's okay with loops but was checking to see if it's possible with ndslice. Zz |
February 18, 2016 Re: ndslice help | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zz | On Thursday, 18 February 2016 at 00:25:09 UTC, Zz wrote: > Hi, > > I'm trying to generate the following sequences with ndslice. > > 0 0 0 > 1 1 1 > > 1 1 1 > 0 0 0 > > 0 1 2 > 0 1 2 > > 2 1 0 > 2 1 0 > > It's okay with loops but was checking to see if it's possible with ndslice. > > Zz Here's my solution: http://dpaste.dzfl.pl/29676608fd88 The best part about ndslice is that you can use the ordinary slice operations with it like: http://dlang.org/spec/arrays.html#array-copying, http://dlang.org/spec/arrays.html#array-setting, http://dlang.org/spec/arrays.html#array-operations, etc. and also leverage the existing ranges, range transformations and algorithms from http://dlang.org/phobos/std_range and http://dlang.org/phobos/std_algorithm. In addition, I used nested array formatting with http://dlang.org/phobos/std_format. |
February 18, 2016 Re: ndslice help | ||||
---|---|---|---|---|
| ||||
Posted in reply to ZombineDev | On Thursday, 18 February 2016 at 02:24:20 UTC, ZombineDev wrote:
> On Thursday, 18 February 2016 at 00:25:09 UTC, Zz wrote:
>> Hi,
>>
>> I'm trying to generate the following sequences with ndslice.
>>
>> 0 0 0
>> 1 1 1
>>
>> 1 1 1
>> 0 0 0
>>
>> 0 1 2
>> 0 1 2
>>
>> 2 1 0
>> 2 1 0
>>
>> It's okay with loops but was checking to see if it's possible with ndslice.
>>
>> Zz
>
> Here's my solution:
> http://dpaste.dzfl.pl/29676608fd88
>
> The best part about ndslice is that you can use the ordinary slice operations with it like:
> http://dlang.org/spec/arrays.html#array-copying,
> http://dlang.org/spec/arrays.html#array-setting,
> http://dlang.org/spec/arrays.html#array-operations, etc.
>
> and also leverage the existing ranges, range transformations and algorithms from
> http://dlang.org/phobos/std_range and
> http://dlang.org/phobos/std_algorithm.
>
> In addition, I used nested array formatting with
> http://dlang.org/phobos/std_format.
Thanks
Zz
|
Copyright © 1999-2021 by the D Language Foundation