<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Oops, you're right on the skipWhile(), that snuck in there because I was looking at the Rust documentation (and Rust uses the name skipWhile()).<br></div>
<div>&nbsp;</div>
<div>As for dropUntil, all of the precedent I know of behaves like a dropWhile, not a dropUntil. And dropUntil sounds weird to me; every time I've wanted to use this functionality, I do in fact want to drop the stuff I don't want, rather than dropping until some predicate becomes true.<br></div>
<div>&nbsp;</div>
<div>Language precedent:<br></div>
<div>&nbsp;</div>
<div>Rust: skip_while() and take_while()<br></div>
<div>Ruby: drop_while() and take_while()<br></div>
<div>Python: dropwhile() and takewhile()<br></div>
<div>Haskell: dropWhile and takeWhile</div>
<div>&nbsp;</div>
<div>-Kevin Ballard</div>
<div>&nbsp;</div>
<div>On Wed, Jan 13, 2016, at 05:54 PM, Dany St-Amant wrote:<br></div>
<blockquote type="cite"><div>The dropWhile sounds weird to me, I usually would see such functionality as a dropUntil; I discard stuff until I see what I want.<br></div>
<div>Your example below doesn’t use dropWhile, but skipWhile; which sounds a bit better that dropWhile as one skip what he doesn’t want.<br></div>
<div>&nbsp;</div>
<div>What do the other languages use? A dropWhile, skipWhile or dropUntil concept?<br></div>
<div>&nbsp;</div>
<div>Dany<br></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><blockquote type="cite"><div>Le 11 janv. 2016 à 01:20, Kevin Ballard via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; a écrit :<br></div>
<div><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div>&nbsp;</div>
<div>Here's a few toy examples, if it helps:<br></div>
<div>&nbsp;</div>
<div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 132, 0);">// list of all powers of 2 below some limit<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">iterate(<span class="colour" style="color:rgb(39, 42, 216)">1</span>, apply: { $0 * <span class="colour" style="color:rgb(39, 42, 216)">2</span> }).takeWhile({ $0 &lt; limit })<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px;">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 132, 0);">// first "word" of a string, skipping whitespace<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;"><span class="colour" style="color:rgb(187, 44, 162)">let</span> cs = NSCharacterSet.whitespaceCharacterSet()<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">String(str.unicodeScalars.skipWhile({ cs.longCharacterIsMember($0.value) })<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .takeWhile({ !cs.longCharacterIsMember($0.value) }))<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px;">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 132, 0);">// running total of an array of numbers<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">numbers.scan(<span class="colour" style="color:rgb(39, 42, 216)">0</span>, combine: +).dropFirst()<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px;">&nbsp;</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0, 132, 0);">// infinite fibonacci sequence<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;">iterate((<span class="colour" style="color:rgb(39, 42, 216)">0</span>,<span class="colour" style="color:rgb(39, 42, 216)">1</span>), apply: { ($1, $0+$1) }).lazy.map({$1})<br></div>
</div>
<div>&nbsp;</div>
<div>-Kevin Ballard<br></div>
<div>&nbsp;</div>
<blockquote type="cite"><div><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;"><div><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;"><div>On Mon, Dec 28, 2015, at 03:59 PM, Kevin Ballard wrote:<br></div>
<div>&gt;<br></div>
<div>&gt; ## Detailed design<br></div>
<div>&gt;<br></div>
<div>&gt; We add the following extension to SequenceType:<br></div>
<div>&gt;<br></div>
<div>&gt; extension SequenceType {<br></div>
<div>&gt;&nbsp; &nbsp; &nbsp;func scan&lt;T&gt;(initial: T, @noescape combine: (T, Self.Generator.Element) throws -&gt; T) rethrows -&gt; [T]<br></div>
<div>&gt;&nbsp; &nbsp; &nbsp;func dropWhile(@noescape dropElement: (Self.Generator.Element) throws -&gt; Bool) rethrows -&gt; [Self.Generator.Element]<br></div>
<div>&gt;&nbsp; &nbsp; &nbsp;func takeWhile(@noescape takeElement: (Self.Generator.Element) throws -&gt; Bool) rethrows -&gt; [Self.Generator.Element]<br></div>
<div>&gt; }<br></div>
<div>&gt;<br></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</div>
</blockquote></div>
</blockquote><div>&nbsp;</div>
</body>
</html>