[swift-users] What makes a good lazy procedure? And how to do it?

Daryle Walker darylew at mac.com
Tue Jan 9 11:01:33 CST 2018


> On Jan 2, 2018, at 11:57 PM, Ben Cohen <ben_cohen at apple.com> wrote:
> 
> I think this is a perfect case for an addition to the existing Lazy suite (and IMO would make a good evolution proposal too, as this kind of “chunked” splitting is a useful feature). You’re right though, there isn’t a good guide out there for how to do this (calling any intrepid blogger who wants to write one…)
> 
> Here’s a sketch of how it would fit into lazy. This is with the latest toolchain from master, which makes things a LOT easier now that IndexDistance is dead. It’s slightly inefficient because it re-uses Index from Base for its index, it would be more efficient to use a start/end pair for the chunks but that’s a lot more code :)
> 
> What’s also interesting is you could (with conditional conformance now that’s landed) make it a RandomAccessCollection if the base were random access, but not if the base is bidirectional, because you need to be able to calculate the size of the last element in constant time.

I got a trial at <https://github.com/CTMacUser/SectionedSequences>.

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20180109/a171f9d7/attachment.html>


More information about the swift-users mailing list