<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 2, 2018, at 11:57 PM, Ben Cohen &lt;<a href="mailto:ben_cohen@apple.com" class="">ben_cohen@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">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…)</div><div class=""><br class=""></div><div class="">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 :)</div><div class=""><br class=""></div><div class="">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 <i class="">not</i>&nbsp;if the base is bidirectional, because you need to be able to calculate the size of the last element in constant time.</div></div></div></blockquote><div><br class=""></div><div>I got a trial at &lt;<a href="https://github.com/CTMacUser/SectionedSequences" class="">https://github.com/CTMacUser/SectionedSequences</a>&gt;.</div><div><br class=""></div><div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">—&nbsp;</div><div class="">Daryle Walker<br class="">Mac, Internet, and Video Game Junkie<br class="">darylew AT mac DOT com&nbsp;</div><div class=""><br class=""></div></div></div></div></div></body></html>