stride in slices
Steven Schveighoffer
schveiguy at yahoo.com
Mon Jun 4 15:43:20 UTC 2018
On 6/3/18 7:13 AM, DigitalDesigns wrote:
> On Sunday, 3 June 2018 at 07:30:56 UTC, Meta wrote:
>> On Saturday, 2 June 2018 at 18:49:51 UTC, DigitalDesigns wrote:
>>> Proposal:
>>>
>>> [a..b;m]
>>>
>>> m is the stride, if ; is not a good char then |, :, !, or # could be
>>> good chars.
>>
>> This is exactly what std.range.stride does. The syntax [a..b;m]
>> directly translates to [a..b].stride(m).
>
>
> So, can I do
>
> X[a..b].stride(m) = 0;
X[a..b].stride(m).fill(0);
> ? Just curious because if it is exactly the same notion then I should be
> able to do it, right?
You are confusing range and array syntax. All of what you want exists,
but isn't necessarily using the same syntax.
> Of course, I'm sure another hoop could be created to jump through and it
> will work, will it still be exactly the same though?
>
> If there is an efficient and optimal setting so one could get the same
> effect, then I guess it might be a direct translation. If not then it
> isn't.
>
> What I am looking for is a sort of zeromemory or memset with stride. It
> should not allocate a new array or be significantly slower. I'd like
> some proof that they are "equivalent" such as a disassembly or a
> profiling... just to satisfy my own skepticism.
fill is what you are looking for.
Note, it's not going to necessarily be as efficient, but it's likely to
be close.
-Steve
More information about the Digitalmars-d
mailing list