[swift-evolution] Feature proposal: Range operator with step
Thorsten Seitz
tseitz42 at icloud.com
Thu Apr 7 00:47:24 CDT 2016
> Am 06.04.2016 um 20:26 schrieb Erica Sadun via swift-evolution <swift-evolution at swift.org>:
>
>>> On Apr 6, 2016, at 12:23 PM, Stephen Canon via swift-evolution <swift-evolution at swift.org> wrote:
>>>
>>>
>>>> On Apr 6, 2016, at 11:20 AM, Stephen Canon via swift-evolution <swift-evolution at swift.org> wrote:
>>>>
>>>> On Apr 6, 2016, at 11:16 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
>>>>
>>>> One question that I *do* think we should answer, is whether the elements
>>>> of
>>>>
>>>> (0..<199).striding(by: -2)
>>>>
>>>> are even or odd.
>>>
>>> Odd. I don’t believe that many real use cases care, but odd is more efficient from a performance perspective. Needs to be documented clearly, however.
>>
>> Sorry, I was thinking of (0…199).striding(by: -2).
>>
>> For the (0..<199) case, Erica’s assessment seems about right, though it isn’t at all obvious how it generalizes to floating point strides.
>
> (l..<h).striding(by: -dX) is undefined for floating point strides as there cannot be a starting value.
Why?
The starting value could quite naturally be s = l + k*dX for the largest value of k in the natural numbers for which s < h, wouldn't it?
-Thorsten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160407/96216c8a/attachment.html>
More information about the swift-evolution
mailing list