<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="">I agree.<div class=""><br class=""></div><div class="">-Thorsten</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">Am 22.01.2016 um 20:10 schrieb Kevin Ballard &lt;<a href="mailto:kevin@sb.org" class="">kevin@sb.org</a>&gt;:</div><br class="Apple-interchange-newline"><div class="">


<title class=""></title>

<div class=""><div class="">I think it's more important here to be consistent with the existing methods (e.g. use `dropWhile()` because we have `dropFirst()`) and any renaming can be discussed as a separate proposal.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">-Kevin Ballard<br class=""></div>
<div class="">&nbsp;</div>
<div class="">On Fri, Jan 22, 2016, at 04:17 AM, Thorsten Seitz wrote:<br class=""></div>
<blockquote type="cite" class=""><div class="">Wouldn't `droppingFirst()` and `droppingWhile()` satisfy the naming conventions?<br class=""></div>
<div class="">The downside is that these are a bit long.<br class=""></div>
<div class="">My hesitation with "skip" is that I'm used to "skip" in the context of streams, not collections, i.e. where I'm forwarding a read position (or cursor) while ignoring the elements passed and not returning the rest.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">-Thorsten<br class=""></div>
<div class=""><div class="">&nbsp;</div>
<div class="">Am 22. Januar 2016 um 08:56 schrieb Kevin Ballard via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><blockquote type="cite" class=""><div style="word-wrap:break-word;" class=""><div class="">I’m tempted to say we should rename dropFirst() / dropWhile() to skipFirst() / skipWhile(), i.e. use Rust’s name, because “skip” doesn’t sound like a mutating verb but I do see why people say “drop” does. But yeah, that would be a different proposal entirely.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">-Kevin Ballard<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><blockquote type="cite" class=""><div class="">On Jan 21, 2016, at 5:02 PM, Andrew Bennett &lt;<a href="mailto:cacoyi@gmail.com" class="">cacoyi@gmail.com</a>&gt; wrote:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div dir="ltr" class="">Great point Kevin, you've convinced me. I'm also happy with `dropWhile` for this reason. My issues with "drop" should be resolved in a separate proposal.<br class=""></div>
<div class=""><div class="">&nbsp;</div>
<div class=""><div class="">On Fri, Jan 22, 2016 at 11:17 AM, Kevin Ballard via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""></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;" class=""><div class=""><u class=""></u><br class=""></div>
<div class=""><div class="">I'm rather opposed to the idea of taking the methods that take indexes and overloading them to take predicates instead. They're extremely different functionality. An index is a value that, once generated, is constant-time to use, and therefore the functions that take them are typically O(1). For example, CollectionType.suffixFrom() is documented explicitly as being O(1).<br class=""></div>
<div class="">&nbsp;</div>
<div class="">But functions taking a predicate must be O(N), because they have to evaluate the predicate on every element in turn until it returns true (or false, depending on the method in question).<br class=""></div>
<div class="">&nbsp;</div>
<div class="">So if we overload suffixFrom() to take a predicate, then we have one function with one overload that's always O(1), and one overload that's always O(N), and that is a great way to confuse people and hide performance issues.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">This is also why I'm particularly fond of the takeWhile / dropWhile terminology. Besides the rather extensive precedent, the inclusion of the word "while" makes it clear that it's iterating over the sequence/collection, which means it's intuitively O(N).<span class=""><span class="colour" style="color:rgb(136, 136, 136)"></span></span><br class=""></div>
<div class="">&nbsp;</div>
<div class="">&nbsp;</div>
<div class=""><span class=""><span class="colour" style="color:rgb(136, 136, 136)">-Kevin Ballard</span></span><br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div class=""><div class="">&nbsp;</div>
<div class="">On Thu, Jan 21, 2016, at 02:57 PM, David Smith wrote:<br class=""></div>
<blockquote type="cite" class=""><div class="">To be honest these all seem equally "weird" looking to me, so my hope is that it's just a matter of familiarity 😊 My personal inclination is still that overloading suffixFrom with a predicate-taking variant is the way to go. That way it occupies the same mental slot as the existing suffixFrom method, and all you have to decide when using it is "do I want to specify where to suffix from, or how to find where to suffix from?". e.g. it basically becomes sugar that turns<br class=""></div>
<div class="">&nbsp;</div>
<div class="">let idx = foo.indexOf { … }<br class=""></div>
<div class="">let suffix = foo.suffixFrom(idx)<br class=""></div>
<div class="">&nbsp;</div>
<div class="">into<br class=""></div>
<div class="">&nbsp;</div>
<div class="">let suffix = foo.suffixFrom { … }<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div class="">with the bonus feature that it works on single-pass sequences.<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div class=""><span style="white-space:pre-wrap;" class=""></span>David<br class=""></div>
<div class=""><div class=""><div class="">&nbsp;</div>
<div class=""><blockquote type="cite" class=""><div class="">On Jan 13, 2016, at 11:52 PM, Kevin Ballard via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div class=""><div class="">"suffixAfter" sounds like the equivalent of dropFirst(_:), i.e. it sounds like it should take a count of elements to skip. Similarly, actually trying an expression that takes a predicate looks weird:<br class=""></div>
<div class="">&nbsp;</div>
<div class="">&nbsp; &nbsp; seq.suffixAfter({ isspace($0) })<br class=""></div>
<div class="">&nbsp;</div>
<div class="">Even knowing what it's supposed to do, it's hard for me to read that expression in any sensible fashion.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">Also, I'm not sure the "noun phrase" convention really makes sense for SequenceType methods. They're not technically mutating methods, but single-pass collections are in fact destructively mutated by Array-returning sequence methods (and the methods that return SubSequence also destructively mutate upon any access to the returned subsequence). Which is to say, despite not being marked as "mutating", they do in fact behave like mutating methods for single-pass sequences. Which suggests that verb phrases are perfectly fine.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">-Kevin Ballard<br class=""></div>
<div class="">&nbsp;</div>
<div class="">On Wed, Jan 13, 2016, at 08:36 PM, David Smith via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><div class="">&nbsp;</div>
<div class="">Rob Rix pointed out that "suffixAfter" would meet all my original criteria. Not sure if keeping the original "match the stuff to drop rather than the stuff to keep" semantics are critical, but this gives us an option for either way 😊<br class=""></div>
<div class="">&nbsp;</div>
<div class="">&nbsp; &nbsp; David<br class=""></div>
<div class=""><div class="">&nbsp;</div>
<div class="">On Jan 13, 2016, at 6:40 PM, David Smith via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
</div>
<blockquote type="cite" class=""><div class=""><div class="">Naming conventions would suggest that something returning a new collection should be named with a noun phrase describing what it returns. Unfortunately, most of the ones I can think of off the top of my head are fairly clunky. "suffixFromFirstNonMatchingElement" describes what it does, but I haven't thought of a non-painful way to say that yet. "suffixExcluding" is almost right, but it incorrectly implies (to my eye at least) that the returned collection excludes all elements matching the predicate, rather than just matching prefixes. Hm, what about flipping the predicate and getting a "suffixFrom" overload that takes a predicate for the first matching element to be included, rather than the last matching element to be excluded?<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><span style="white-space:pre-wrap;" class=""></span>David<br class=""></div>
<div class=""><div class="">&nbsp;</div>
<div class=""><blockquote type="cite" class=""><div class="">On Jan 13, 2016, at 5:54 PM, Dany St-Amant via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div style="word-wrap:break-word;" 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.<br class=""></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.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">What do the other languages use? A dropWhile, skipWhile or dropUntil concept?<br class=""></div>
<div class="">&nbsp;</div>
<div class="">Dany<br class=""></div>
<div class="">&nbsp;</div>
<div class="">&nbsp;</div>
<div class=""><blockquote type="cite" class=""><div class="">Le 11 janv. 2016 à 01:20, Kevin Ballard via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :<br class=""></div>
<div class=""><div style="word-wrap:break-word;" class=""><div class="">&nbsp;</div>
<div class="">Here's a few toy examples, if it helps:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div style="font-size:11px;line-height:normal;font-family:menlo;color:rgb(0, 132, 0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">// list of all powers of 2 below some limit<br class=""></div>
<div style="font-size:11px;line-height:normal;font-family:menlo;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">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 class=""></div>
<div style="font-size:11px;line-height:normal;font-family:menlo;min-height:13px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">&nbsp;</div>
<div style="font-size:11px;line-height:normal;font-family:menlo;color:rgb(0, 132, 0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">// first "word" of a string, skipping whitespace<br class=""></div>
<div style="font-size:11px;line-height:normal;font-family:menlo;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class=""><span class="colour" style="color:rgb(187, 44, 162)">let</span> cs = NSCharacterSet.whitespaceCharacterSet()<br class=""></div>
<div style="font-size:11px;line-height:normal;font-family:menlo;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">String(str.unicodeScalars.skipWhile({ cs.longCharacterIsMember($0.value) })<br class=""></div>
<div style="font-size:11px;line-height:normal;font-family:menlo;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .takeWhile({ !cs.longCharacterIsMember($0.value) }))<br class=""></div>
<div style="font-size:11px;line-height:normal;font-family:menlo;min-height:13px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">&nbsp;</div>
<div style="font-size:11px;line-height:normal;font-family:menlo;color:rgb(0, 132, 0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">// running total of an array of numbers<br class=""></div>
<div style="font-size:11px;line-height:normal;font-family:menlo;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">numbers.scan(<span class="colour" style="color:rgb(39, 42, 216)">0</span>, combine: +).dropFirst()<br class=""></div>
<div style="font-size:11px;line-height:normal;font-family:menlo;min-height:13px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">&nbsp;</div>
<div style="font-size:11px;line-height:normal;font-family:menlo;color:rgb(0, 132, 0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">// infinite fibonacci sequence<br class=""></div>
<div style="font-size:11px;line-height:normal;font-family:menlo;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class="">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 class=""></div>
</div>
<div class="">&nbsp;</div>
<div class="">-Kevin Ballard<br class=""></div>
<div class="">&nbsp;</div>
<blockquote type="cite" class=""><div class=""><blockquote style="border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;" class=""><div class=""><blockquote style="border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;" class=""><div class="">On Mon, Dec 28, 2015, at 03:59 PM, Kevin Ballard wrote:<br class=""></div>
<div class="">&gt;<br class=""></div>
<div class="">&gt; ## Detailed design<br class=""></div>
<div class="">&gt;<br class=""></div>
<div class="">&gt; We add the following extension to SequenceType:<br class=""></div>
<div class="">&gt;<br class=""></div>
<div class="">&gt; extension SequenceType {<br class=""></div>
<div class="">&gt;&nbsp; &nbsp; &nbsp;func scan&lt;T&gt;(initial: T, @noescape combine: (T, Self.Generator.Element) throws -&gt; T) rethrows -&gt; [T]<br class=""></div>
<div class="">&gt;&nbsp; &nbsp; &nbsp;func dropWhile(@noescape dropElement: (Self.Generator.Element) throws -&gt; Bool) rethrows -&gt; [Self.Generator.Element]<br class=""></div>
<div class="">&gt;&nbsp; &nbsp; &nbsp;func takeWhile(@noescape takeElement: (Self.Generator.Element) throws -&gt; Bool) rethrows -&gt; [Self.Generator.Element]<br class=""></div>
<div class="">&gt; }<br class=""></div>
<div class="">&gt;<br class=""></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</div>
</blockquote></div>
<div class="">&nbsp;</div>
<div class=""><img width="1" height="1" border="0" style="min-height:1px;width:1px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" alt="" class=""><br class=""></div>
</div>
<div class="">_______________________________________________<br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</div>
</blockquote></div>
</div>
<div class=""><img width="1" height="1" border="0" style="min-height:1px;width:1px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" alt="" class=""><br class=""></div>
</div>
</blockquote><blockquote type="cite" class=""><div class=""><div class=""><span class="">_______________________________________________</span><br class=""></div>
<div class=""><span class="">swift-evolution mailing list</span><br class=""></div>
<div class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""></div>
<div class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div>
</div>
</blockquote><div class=""><img width="1" height="1" border="0" style="min-height:1px;width:1px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" alt="" class=""><br class=""></div>
<div class=""><u class="">_______________________________________________</u><br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</blockquote><div class="">&nbsp;</div>
<div class=""><img width="1" height="1" border="0" alt="" style="min-height:1px;width:1px;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;" class=""><br class=""></div>
</div>
<div class="">_______________________________________________<br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</div>
</blockquote></div>
</div>
</div>
</div>
</div>
</blockquote><div class="">&nbsp;</div>
</div>
</div>
</div>
<div class="">&nbsp;</div>
<div class="">_______________________________________________<br class=""></div>
<div class=""> swift-evolution mailing list<br class=""></div>
<div class=""> <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
<div class="">&nbsp;</div>
</blockquote></div>
</div>
</div>
</blockquote></div>
</div>
</blockquote></div>
</div>
</blockquote><div class="">&nbsp;</div>
</div>

</div></blockquote></div><br class=""></div></body></html>