<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=""><div class="">The dropWhile sounds weird to me, I usually would see such functionality as a dropUntil; I discard stuff until I see what I want.</div><div class="">Your example below doesn’t use dropWhile, but skipWhile; which sounds a bit better that dropWhile as one skip what he doesn’t want.</div><div class=""><br class=""></div><div class="">What do the other languages use? A dropWhile, skipWhile or dropUntil concept?</div><div class=""><br class=""></div><div class="">Dany</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">Le 11 janv. 2016 à 01:20, Kevin Ballard via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div>
<div class="">Here's a few toy examples, if it helps:<br class=""></div>
<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// list of all powers of 2 below some limit</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">iterate(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>, apply: { $0 * <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span> }).takeWhile({ $0 < limit })</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; color: rgb(0, 132, 0);" class="">// first "word" of a string, skipping whitespace</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> cs = NSCharacterSet.whitespaceCharacterSet()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">String(str.unicodeScalars.skipWhile({ cs.longCharacterIsMember($0.value) })</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> .takeWhile({ !cs.longCharacterIsMember($0.value) }))</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; color: rgb(0, 132, 0);" class="">// running total of an array of numbers</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">numbers.scan(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>, combine: +).dropFirst()</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; color: rgb(0, 132, 0);" class="">// infinite fibonacci sequence</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">iterate((<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span>,<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>), apply: { ($1, $0+$1) }).lazy.map({$1})</div></div>
<div class=""><br class=""></div>
<div class="">-Kevin Ballard</div>
<div class=""><br class=""></div>
<blockquote type="cite" class=""><div class=""><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;" class=""><div class=""><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;" class=""><div class="">On Mon, Dec 28, 2015, at 03:59 PM, Kevin Ballard wrote:<br class=""></div>
<div class="">></div>
<div class="">
> ## Detailed design<br class=""></div>
<div class="">
><br class=""></div>
<div class="">
> We add the following extension to SequenceType:<br class=""></div>
<div class="">
><br class=""></div>
<div class="">
> extension SequenceType {<br class=""></div>
<div class="">
> func scan<T>(initial: T, @noescape combine: (T, Self.Generator.Element) throws -> T) rethrows -> [T]<br class=""></div>
<div class="">
> func dropWhile(@noescape dropElement: (Self.Generator.Element) throws -> Bool) rethrows -> [Self.Generator.Element]<br class=""></div>
<div class="">
> func takeWhile(@noescape takeElement: (Self.Generator.Element) throws -> Bool) rethrows -> [Self.Generator.Element]<br class=""></div>
<div class="">
> }<br class=""></div>
<div class="">
><br class=""></div>
</blockquote></div></blockquote></div></blockquote></div></div></blockquote></div><br class=""></body></html>