[swift-evolution] [Proposal] Decoupling Floating Point Strides from Generic Implementations

Erica Sadun erica at ericasadun.com
Tue Mar 1 10:48:22 CST 2016


I can't remember if I responded to this yet or not, since I just added an algorithm to the proposal and am finishing tweaks.

Strides can progress negatively as well as positively, and ranges don't support that. 

(0.0)...(-1.2) returns fatal error: Invalid ClosedInterval bounds (end < start)

Take a look at the updated proposal with the more precise second algorithm.

-- E


> On Mar 1, 2016, at 12:44 AM, Howard Lovatt <howard.lovatt at gmail.com> wrote:
> 
> Your implementation of `fstride` is faulty, it doesn't produce the `through` value. Suggest you change to:
> 
> public extension Double {
>     public func doubleStride(through end: Double, by stride: Double) -> LazyMapCollection<Range<Int>, Double> {
>         let limit = Int(trunc((end - self) / stride))
>         return (0 ... limit).lazy.map { self + Double($0) * stride }
>     }
> }
> 
> 
>   -- Howard.
> 
> On 1 March 2016 at 12:16, Erica Sadun via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> On Feb 29, 2016, at 5:03 PM, Joe Groff <jgroff at apple.com <mailto:jgroff at apple.com>> wrote:
>>> I agree, splitting into two proposals is a good idea.
>>> 
>>> -Joe
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160301/56e92bdd/attachment.html>


More information about the swift-evolution mailing list