<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">It is tough to give examples which are suitably approachable, illustrative, and complex. Perhaps the Fibonacci sequence:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">generator func fibonacci() -> Int {</div><div class=""> var = 0, j = 1</div><div class=""> repeat {</div><div class=""> (i, j) = (j, i + j)</div><div class=""> yield i</div><div class=""> }</div><div class="">}</div></blockquote><div class=""><br class=""></div><div class="">In addition to being a more complex problem, the sequence is also infinite. Luckily the functional influences on sequences let you deal with that without issue:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">// print the first 25 numbers in the fibonacci sequence</div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">fibonacci().prefix(25).forEach { print($0) }</div></blockquote><div class=""><br class=""></div>-DW<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 11, 2015, at 6:38 PM, Kametrixom Tikara <<a href="mailto:kametrixom@icloud.com" class="">kametrixom@icloud.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">What exactly is the difference to just returning a sequence?</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""><span class="" style="color: rgb(53, 86, 138);">func</span><span class="Apple-converted-space"> </span>helloGenerator(name :<span class="Apple-converted-space"> </span><span class="" style="color: rgb(195, 89, 0);">String</span>?) -> [<span class="" style="color: rgb(195, 89, 0);">String</span>] {</font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(53, 86, 138);">return</span><span class="Apple-converted-space"> </span>[</font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(232, 35, 0);">"Hello"</span>,</font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""> name ??<span class="Apple-converted-space"> </span><span class="" style="color: rgb(232, 35, 0);">"World"</span></font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""> ]</font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class="">}</font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 16px;"><font size="1" class=""><br class=""></font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(88, 126, 168);"><font size="1" class=""><span class="" style="color: rgb(53, 86, 138);">for</span><span class="" style=""><span class="Apple-converted-space"> </span>str<span class="Apple-converted-space"> </span></span><span class="" style="color: rgb(53, 86, 138);">in</span><span class="" style=""><span class="Apple-converted-space"> </span></span>helloGenerator<span class="" style="">(</span><span class="" style="color: rgb(232, 35, 0);">"David"</span><span class="" style="">) {</span></font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(88, 126, 168);">print</span>(str)</font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class="">}</font></div><div class=""><br class=""></div><div class="">And if you want if lazy:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""><span class="" style="color: rgb(53, 86, 138);">func</span><span class="Apple-converted-space"> </span>helloGenerator(name :<span class="Apple-converted-space"> </span><span class="" style="color: rgb(195, 89, 0);">String</span>?) -><span class="Apple-converted-space"> </span><span class="" style="color: rgb(195, 89, 0);">LazyCollection</span><[<span class="" style="color: rgb(195, 89, 0);">String</span>]> {</font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(53, 86, 138);">return</span><span class="Apple-converted-space"> </span>[</font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""> <span class="Apple-converted-space"> </span><span class="" style="color: rgb(232, 35, 0);">"Hello"</span>,</font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""> name ??<span class="Apple-converted-space"> </span><span class="" style="color: rgb(232, 35, 0);">"World"</span></font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class=""> ].<span class="" style="color: rgb(88, 126, 168);">lazy</span></font></div><div class="" style="margin: 0px; line-height: normal; font-family: Menlo;"><font size="1" class="">}</font></div></div></div></div></blockquote></div><br class=""></div></body></html>