[swift-evolution] [Discussion] stride behavior and a little bit of a call-back to digital numbers
Joe Groff
jgroff at apple.com
Mon Feb 29 17:48:38 CST 2016
> On Feb 27, 2016, at 6:54 PM, Erica Sadun <erica at ericasadun.com> wrote:
>
>
>> On Feb 27, 2016, at 7:30 PM, Joe Groff via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> Forloopians probably don't care whether Float is Strideable, as long as it
>> has working stride methods. If those methods are better than what they'd
>> write naively, well, that's even better justification for taking the C loop
>> away.
>
> How about something like https://gist.github.com/erica/3cd5633b9e139844aa5a <https://gist.github.com/erica/3cd5633b9e139844aa5a>
Functionally that seems reasonable. IMO it wouldn't be a problem to call the Double variant `stride(through:by:)` to match the integer form. Just for fun, you could simplify the condition here:
if stride > 0.0 ? current >= end : current <= end {
by using 'if signbit(current - end) == signbit(stride)' instead.
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160229/c2ccb0cd/attachment.html>
More information about the swift-evolution
mailing list