<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>"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></div>
<div> </div>
<div> seq.suffixAfter({ isspace($0) })<br></div>
<div> </div>
<div>Even knowing what it's supposed to do, it's hard for me to read that expression in any sensible fashion.<br></div>
<div> </div>
<div>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></div>
<div> </div>
<div>-Kevin Ballard<br></div>
<div> </div>
<div>On Wed, Jan 13, 2016, at 08:36 PM, David Smith via swift-evolution wrote:<br></div>
<blockquote type="cite"><div> </div>
<div>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></div>
<div> </div>
<div> David<br></div>
<div><div> </div>
<div>On Jan 13, 2016, at 6:40 PM, David Smith via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div>
</div>
<blockquote type="cite"><div><div>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></div>
<div> </div>
<div><span style="white-space:pre;"></span>David<br></div>
<div><div> </div>
<div><blockquote type="cite"><div>On Jan 13, 2016, at 5:54 PM, Dany St-Amant via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div>
<div> </div>
<div><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><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> </div>
<div>What do the other languages use? A dropWhile, skipWhile or dropUntil concept?<br></div>
<div> </div>
<div>Dany<br></div>
<div> </div>
<div> </div>
<div><blockquote type="cite"><div>Le 11 janv. 2016 à 01:20, Kevin Ballard via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> a écrit :<br></div>
<div><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div> </div>
<div>Here's a few toy examples, if it helps:<br></div>
<div> </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 < 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;"> </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;"> .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;"> </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;"> </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> </div>
<div>-Kevin Ballard<br></div>
<div> </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>><br></div>
<div>> ## Detailed design<br></div>
<div>><br></div>
<div>> We add the following extension to SequenceType:<br></div>
<div>><br></div>
<div>> extension SequenceType {<br></div>
<div>> func scan<T>(initial: T, @noescape combine: (T, Self.Generator.Element) throws -> T) rethrows -> [T]<br></div>
<div>> func dropWhile(@noescape dropElement: (Self.Generator.Element) throws -> Bool) rethrows -> [Self.Generator.Element]<br></div>
<div>> func takeWhile(@noescape takeElement: (Self.Generator.Element) throws -> Bool) rethrows -> [Self.Generator.Element]<br></div>
<div>> }<br></div>
<div>><br></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</div>
</blockquote></div>
<div> </div>
<div> <img style="height:1px !important;width:1px !important;border-top-width:0px !important;border-right-width:0px !important;border-bottom-width:0px !important;border-left-width:0px !important;margin-top:0px !important;margin-bottom:0px !important;margin-right:0px !important;margin-left:0px !important;padding-top:0px !important;padding-bottom:0px !important;padding-right:0px !important;padding-left:0px !important;" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/b56f62c953dd35e47af9e35e7e65cf5da4571de9045c2d6d82524566e169b0bf/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d316546573364777448753a4d426f45394450325d22364d2236496d22364943643d6258357e41384d223642505143763c45664368373e6931364569745f43383252653038623a78446d6a6754457a4951787c6b4a4b4739794f4b6e4570324d22324676646f47507736425b4d2232464953567a51686d2236453979796f65364d2236417f474d2236435b674333553256514361536544374a6c4d6136375c64396b625b47324c653a584f626178734342374644367b6d223244715d63593d485d41353350393f64517830753b434075313b47533762596a4864526b4334533e686a6f6b6545734054664433345277654a4b683f42316537397d4332363b44794d23344/open"><br></div>
</div>
<div>_______________________________________________<br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</div>
</blockquote></div>
</div>
<div><img style="height:1px !important;width:1px !important;border-top-width:0px !important;border-right-width:0px !important;border-bottom-width:0px !important;border-left-width:0px !important;margin-top:0px !important;margin-bottom:0px !important;margin-right:0px !important;margin-left:0px !important;padding-top:0px !important;padding-bottom:0px !important;padding-right:0px !important;padding-left:0px !important;" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/eefeab9f47621fc0b43c8cdd386775462df532f089815082ba12e8f2b7adea88/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d316546573364777448753a4d426f45394450325d22364d2236496d22364943643d6258357e41384d223642505143763c456644603a705864577376316969385b6f634848353742455d6244375a54436762336956736274366a77717d223641447146346d4d64456577623766494d4a58464e65745e476e6f6167585c607252427b62643173456441524a7b41546a6c4967683669334b6263466a5734395a467d223244305149645055685152535b497348754d223243587f453d22364d4d2236437637354970726630383859424a5c6a48377652487436567a555537574d495360526f637472553868303842774566777533547f675949797b6260575b6d23344/open"><br></div>
</div>
</blockquote><blockquote type="cite"><div><div><span>_______________________________________________</span><br></div>
<div><span>swift-evolution mailing list</span><br></div>
<div><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br></div>
<div><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div>
</div>
</blockquote><div><img style="height:1px !important;width:1px !important;border-top-width:0px !important;border-right-width:0px !important;border-bottom-width:0px !important;border-left-width:0px !important;margin-top:0px !important;margin-bottom:0px !important;margin-right:0px !important;margin-left:0px !important;padding-top:0px !important;padding-bottom:0px !important;padding-right:0px !important;padding-left:0px !important;" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/24301e8416e759fb8f0fab5459bef80dc19fa9fb7657df4a14f4b7a0f2f17783/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d3148765176786c673171614a7d2236454230345272776e44675f66733d22324d634967724848326e41554c4074695a50335473444943536d223244575b44536857644a6a7a64434a59305b494d22364238545b666734474c425265544645763454476033454540705b44343d415772707d22324d42555070386d22364570383b44593871685332796751523952665f4632623a6545697d223647754639614f43753e4163463d2236493377517f4e6166585b6a7173324c4f485161486b46763d22364f673c62755b4671523474755070565051346b6b675c433078513156705470735d6d437144477d23344d23344/open"><br></div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div> </div>
</body>
</html>