<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">OK, maybe I need to think about this more carefully. &nbsp;Sorry if I drew incorrect/hasty conclusions.<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 16, 2015, at 11:35 AM, Donnacha Oisín Kidney &lt;<a href="mailto:oisin.kidney@gmail.com" class="">oisin.kidney@gmail.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; -webkit-line-break: after-white-space;" class="">Oops, sorry, I wasn’t very clear. I was just trying to compare the amount of code reuse and new types between the two versions.&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">CollectionOfZeroOrOne</span>&nbsp;would need three extensions (<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">SequenceType</span>,&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">CollectionType</span>&nbsp;&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">BidirectionalIndexType</span>&nbsp; as well as the extra struct itself. The filter version doesn’t <i class="">really</i>&nbsp;need a new struct, but to have a bidirectional version, you would need a&nbsp;<span style="color: rgb(112, 61, 170); font-family: Menlo; font-size: 11px;" class="">LazyFilterBidirectionalCollection</span>&nbsp; which doesn’t currently exist. I had thought that that was something which may be added anyway, though.<br class=""><div class=""><br class=""></div><div class="">Oisin.</div><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 16 Dec 2015, at 19:08, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" class="">dabrahams@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; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 16, 2015, at 10:15 AM, Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 16, 2015 at 7:10 AM, Donnacha Oisín Kidney <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Now that I think about it, of course&nbsp;<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">CollectionOfZeroOrOne</span>&nbsp;would (or&nbsp;<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">Optional</span>) have a random access index. I’ll update the proposal to include that.<br class=""><div class=""><br class=""></div><div class="">I really like the&nbsp;<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">CollectionOfZeroOrOne</span>&nbsp;solution. The semantics and types certainly make more sense. I’m not sure that it reduces the amount of code, though: the three extensions are still needed, plus an extra struct. (I suppose that’s not counting the extra version of&nbsp;<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">LazyFilterCollection</span>. Am I right in saying that that is intended to be added?)</div></div></blockquote></div></div></div></div></blockquote><div class=""><br class=""></div>I'm not sure I understand why we need another version of LazyFilterCollection. &nbsp;Can you explain?</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Here’s what I have for the collection (I tried to mimic the standard library’s&nbsp;<span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px" class="">CollectionOfOne</span>):</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:#bb2ca2" class="">public</span> <span style="color:#bb2ca2" class="">struct</span> CollectionOfZeroOrOne&lt;Element&gt; : <span style="color:#703daa" class="">CollectionType</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><font class="">[...]</font></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">}</div></div><div class=""><br class=""></div><div class="">Does that seem reasonable?</div></div></blockquote><div class=""><br class=""></div><div class="">It looks reasonable, but I don't understand why adding CollectionOfZeroOrOne improves the API.&nbsp; Dave?</div></div></div></div></div></blockquote><div class=""><br class=""></div>It doesn't. &nbsp;I think it improves code reuse, and gives people an adapter to use when they want to pass an Optional where a Collection or Sequence is required.</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Dmitri</div><div class="">&nbsp;</div></div>-- <br class=""><div class="gmail_signature">main(i,j){for(i=2;;i++){for(j=2;j&lt;i;j++){if(!(i%j)){j=0;break;}}if<br class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" target="_blank" class="">gribozavr@gmail.com</a>&gt;*/</div>
</div></div>
</div></blockquote></div><br class=""><div class="">
-Dave<div class=""><br class=""></div><br class="Apple-interchange-newline">

</div>
<br class=""></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""><div class="">
-Dave<div class=""><br class=""></div><br class="Apple-interchange-newline">

</div>
<br class=""></div></body></html>