lockstep alternative for StoppingPolicy.longest

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Sep 17 16:03:42 PDT 2012


On 9/18/12, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> On 9/18/12, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
>>     foreach (aa, bb; lockstep(arr1, arr2))
>>     {
>>         if (aa == sentinel)
>>         {
>>             if (aa % 2 == 0)
>
> Gah I've messed up the simple example. If aa was a sentinel then it
> meant I wouldn't check it at all, I'd try to check 'bb' instead.
>

Here we go: http://dpaste.dzfl.pl/dff850fb

Hardcoded but could be made to work with multiple ranges (+ i have way
too many runtime checks there). For floating-point this might even
work since a sentinel could be NaN, but for ints there's no reasonable
sentinel. We could use pointers instead and use NULL when the range is
empty.


More information about the Digitalmars-d-learn mailing list