[swift-evolution] [Discussion] stride behavior and a little bit of a call-back to digital numbers

Dany St-Amant dsa.mls at icloud.com
Sun Feb 28 10:46:53 CST 2016


> Le 27 févr. 2016 à 21:54, Erica Sadun via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> 
>> 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>
> 

This implementation with: 
        let current = start + Double(self.iteration) * stride

does have the advantage of also fixing the following infinite loop (even though this example is bit silly)

for data in 1_000_000_000_000_000.0.stride(to:1_000_000_000_000_001.0, by:0.05)
{
    print(data)
}

Dany
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160228/75be6b16/attachment-0001.html>


More information about the swift-evolution mailing list