<div dir="ltr">sequence can have more methods with it, we can find first five values of a sequence.<div><br></div><div>but we don&#39;t do this with a generator<br><div><br></div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">struct</span> Fibonacci: <span style="color:rgb(112,61,170)">SequenceType</span> {</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px">    </p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(187,44,162)">var</span> first, second: <span style="color:rgb(112,61,170)">Int</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px">    </p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    <span style="color:rgb(187,44,162)">func</span> generate() -&gt; <span style="color:rgb(112,61,170)">AnyGenerator</span>&lt;<span style="color:rgb(112,61,170)">Int</span>&gt; {</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px">        </p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        <span style="color:rgb(187,44,162)">var</span> a = <span style="color:rgb(79,129,135)">first</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        <span style="color:rgb(187,44,162)">var</span> b = <span style="color:rgb(79,129,135)">second</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px">        </p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(61,29,129)"><span style="color:rgb(0,0,0)">        </span><span style="color:rgb(187,44,162)">return</span><span style="color:rgb(0,0,0)"> </span>anyGenerator<span style="color:rgb(0,0,0)"> {</span></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">            <span style="color:rgb(187,44,162)">let</span> temp = a</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">            (a, b) = (b, a + b)</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">            <span style="color:rgb(187,44,162)">return</span> temp</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">        }</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">    }</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(112,61,170)">Array</span>(<span style="color:rgb(79,129,135)">Fibonacci</span>(first: <span style="color:rgb(39,42,216)">1</span>, second: <span style="color:rgb(39,42,216)">1</span>).<span style="color:rgb(61,29,129)">prefix</span>(<span style="color:rgb(39,42,216)">10</span>))</p></div></div><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div><span style="font-size:14px">Happy new year to all</span><br></div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-31 21:57 GMT+08:00 Dmitri Gribenko <span dir="ltr">&lt;<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Dec 31, 2015 at 3:36 PM, Susan Cheng &lt;<a href="mailto:susan.doggie@gmail.com">susan.doggie@gmail.com</a>&gt; wrote:<br>
&gt; I don&#39;t think so.<br>
&gt;<br>
&gt; As we don&#39;t say &quot;Fibonacci collection&quot;, we know Fibonacci numbers are in<br>
&gt; order. But we can&#39;t tell the number immediately if I asked a specific index<br>
&gt; of Fibonacci sequence. The only way is calculate the sequence one by one<br>
&gt; from start.<br>
<br>
</span>That&#39;s OK, collections can have Forward indices which have exactly<br>
these properties.<br>
<div class="HOEnZb"><div class="h5"><br>
Dmitri<br>
<br>
--<br>
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">gribozavr@gmail.com</a>&gt;*/<br>
</div></div></blockquote></div><br></div>