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

William Dillon william at housedillon.com
Sat Feb 27 17:45:41 CST 2016


I like this proposal. Even the corrected integer case feels more correct to me. I think that the core of stride is (not surprisingly) the stride.

So, in the integer case as well as the floating case, I would expect through to stride past the terminus if it isn’t an integer multiple of the stride in the through case. Likewise, of course, it would stop before the end in the to case.

+1 from me.

- Will





On February 27, 2016 at 3:36:41 PM, Erica Sadun via swift-evolution (swift-evolution at swift.org) wrote:

The documentation is a bit weird. "It returns the sequence where last is less than or equal to `end`.” seems to tacitly assume that we’re talking about the longest possible sequence with that property. With your proposed "It returns the sequence where last is greater than or equal to `end`?” we’re now talking about the shortest possible sequence with that property.

But what do you mean “no change for integers”? What about 1.stride(through: 10, by: 8)? Wouldn’t that return [1, 9] now and [1, 9, 17] with your change?

It means, I'm wrong about that. Fixing here, both in code and in text: https://gist.github.com/erica/03c398c06f6c47824429

print(Array(1.stride(through: 10, by: 8)))
[1, 9]

print(Array(1.stride(through2: 10, by: 8))) // my test implementation
[1, 9, 17]

The second progress now goes *through* 10.

-- E
_______________________________________________
swift-evolution mailing list
swift-evolution at swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160227/9b3719eb/attachment.html>


More information about the swift-evolution mailing list