<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 16, 2015 at 7:10 AM, Donnacha Oisín Kidney <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Now that I think about it, of course <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">CollectionOfZeroOrOne</span> would (or <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">Optional</span>) have a random access index. I’ll update the proposal to include that.<br><div><br></div><div>I really like the <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">CollectionOfZeroOrOne</span> 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 <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">LazyFilterCollection</span>. Am I right in saying that that is intended to be added?)</div><div><br></div><div>Here’s what I have for the collection (I tried to mimic the standard library’s <span style="color:rgb(112,61,170);font-family:Menlo;font-size:11px">CollectionOfOne</span>):</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">public</span> <span style="color:#bb2ca2">struct</span> CollectionOfZeroOrOne&lt;Element&gt; : <span style="color:#703daa">CollectionType</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><font color="#000000">[...]</font></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></div><div><br></div><div>Does that seem reasonable?</div></div></blockquote><div><br></div><div>It looks reasonable, but I don&#39;t understand why adding CollectionOfZeroOrOne improves the API.  Dave?</div><div><br></div><div>Dmitri</div><div> </div></div>-- <br><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>(j){printf(&quot;%d\n&quot;,i);}}} /*Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>&gt;*/</div>
</div></div>