<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=""><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="">Hi Daryle,<div class=""><br class=""></div><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></div></blockquote><div><br class=""></div><div>I saw that I missed this discussion when I skipped out for 1.5 months. I’m not sure what the problem with IndexDistance was; abstraction is generally a good thing. Wouldn’t any awkwardness with “let x: IndexDistance = 0” affect ALL types besides Int? If you have a problem with that, then the solution would be to redo Swift’s literal-handling model.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><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>Is this active, at least in Xcode 9.2? Because I couldn’t get the obvious:</div><div><br class=""></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div><div><font face="Monaco" class="">extension&nbsp;ChunkedCollection:&nbsp;RandomAccessCollection&nbsp;where&nbsp;Base: RandomAccessCollection {</font></div></div><div><div><font face="Monaco" class="">&nbsp; &nbsp; //…</font></div></div><div><div><font face="Monaco" class="">}</font></div></div></blockquote><div><div><br class=""></div><div>to work. (An extension with constraints can’t have an inheritance clause.)</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=""></div></div></div></div></div><br class=""></body></html>