<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 21, 2016, at 5:46 PM, Ted F.A. van Gaalen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" 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=""><blockquote type="cite" class=""><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="">There are many empty strings in that string. In fact, there are infinite empty strings between each character, before the string, and after the string. Observe:</div><div class=""><br class=""></div><div class="">"" + "Don’t Panic: Please read Hitchhiker’s Guide to the Galaxy 42"</div><div class=""><div class=""><div class="">"" + "" + "Don’t Panic: Please read Hitchhiker’s Guide to the Galaxy 42"</div></div></div><div class=""><div class=""><div class="">"" + "" + "" + "Don’t Panic: Please read Hitchhiker’s Guide to the Galaxy 42"</div></div></div><div class=""><div class="">"" + "" + "" + "" + "Don’t Panic: Please read Hitchhiker’s Guide to the Galaxy 42"</div></div><div class="">etc, and I didn't even get past the first character!</div><div class=""><br class=""></div></div></div></blockquote></div><div class="">Wel, maybe I am not intelligent enough to comprehend that,</div><div class="">or maybe it’s just a matter of definition/convention..</div><div class=""> </div><div class="">Again, to me a string is ***just a row of characters***. </div></div></div></blockquote><div><br class=""></div><div>In which case it should be even more confusing to you:</div><div><br class=""></div><div><div style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> str = </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Hello"</span></div><div style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">str</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="color: rgb(112, 61, 170); font-variant-ligatures: no-common-ligatures;" class="">characters</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);" class="">starts</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(with: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);" class="">""</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="color: rgb(112, 61, 170); font-variant-ligatures: no-common-ligatures;" class="">characters</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)</span> // true</span></div><div style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo; color: rgb(61, 29, 129);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">str</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span><span style="font-variant-ligatures: no-common-ligatures" class="">hasPrefix</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">""</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">) // false</span></div></div><div><br class=""></div><blockquote type="cite" class=""><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="">therefore, concatenating empty strings (that do not contain any characters) with other strings have no effect: . </div><div class="">for example: </div><div class=""><br class=""></div><div class=""> let res = "" + "" + "" + "" + “The Art Of Learning To Fly”</div><div class=""><br class=""></div><div class="">after that: </div><div class=""> </div><div class=""> res == “The Art Of Learning To Fly”</div><div class=""><br class=""></div><div class="">and:</div><div class=""><br class=""></div><div class=""> res.count == “The Art Of Learning To Fly”.count</div><div class=""><br class=""></div><div class="">Regardless what in many other programming languages is done;</div><div class="">I prefer the Objective jC NSString hasPrefix(“") way of handling this,</div><div class="">which always returns False,e because a row of characters</div><div class="">is contiguous, without empty “” in between, leading or trailing. </div><div class=""><br class=""></div><div class="">However, we don’t seem to share the same opinion, about this sorry. </div><div class="">nothing more to say about that, I guess.</div><div class=""><br class=""></div><div class="">TedvG</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class="">On Jul 20, 2016, at 6:49 PM, Ted F.A. van Gaalen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Don’t Panic !</div><div class=""><br class=""></div><div class="">At the risk of seeing things in a somewhat trivial perspective,</div><div class="">combined with an almost complete absence of abstraction:</div><div class=""><br class=""></div><div class="">Note that to relatively simple persons like me: </div><div class=""><br class=""></div><div class="">String instances are just rows of characters (when not empty, of course) </div><div class=""><br class=""></div><div class="">There are only two kinds of Strings:</div><div class=""><br class=""></div><div class="">1. empty Strings, which do not contain amy characters at all</div><div class=""><br class=""></div><div class=""> and </div><div class=""><br class=""></div><div class="">2. Strings containing 1 or more characters.</div><div class=""><br class=""></div><div class="">Ergo ad Infinitum :</div><div class=""><br class=""></div><div class="">Empty Strings do not occur in Strings that contain characters. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I’d say, please try to find possible empty strings</div><div class="">that might perhaps be embedded e.g. in the string below: </div><div class=""> </div><div class="">“Don’t Panic: Please read Hitchhiker’s Guide to the Galaxy 42” </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">With all due respect: </div><div class="">This might void the discussion below :o)</div><div class=""><br class=""></div><div class="">I have nothing against Mathematics as long</div><div class="">as it is applicable.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Kind Regards</div><div class="">Ted</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><span style="font-size: 14.25px;" class="">To the question of whether any given string has the empty string as prefix:</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">yes it does. This is a correct answer, and returning true is a correct</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">behaviour.</span><br style="font-size: 14.25px;" class=""><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">To the question of how many times the empty string occurs in a string: yes,</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">this can be infinite. "a" == "a" + "" == "a" + "" + "" == "a" + "" + "" +</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">"" == "a" + "" + "" + "" + "" == ... etc.. Concatenating an empty string,</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">like adding zero or multiplying by zero for a numerical value, can be done</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">infinitely many times without making a difference.</span><br style="font-size: 14.25px;" class=""><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">However, there's correctness and convenience. For example, every integer</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">can be expressed as a multiple of prime factors. 1 is technically a prime</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">number - it's divisible by 1 and itself - but for convenience we say it</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">isn't a prime number, because if it isn't, every integer can be expressed</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">uniquely as a multiple of prime factors, whereas if it is, there are an</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">infinite number of such expressions for each integer.</span><br style="font-size: 14.25px;" class=""><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">There may be many algorithms which rely on an empty prefix returning false.</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">If hasPrefix and hasSuffix are corrected, those algorithms should be</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">altered to recognise that correction. For example, if breaking up a string</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">using the empty string as a separator, it seems sensible that the sequence</span><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">of substrings would never contain consecutive empty strings.</span><br style="font-size: 14.25px;" class=""><br style="font-size: 14.25px;" class=""><span style="font-size: 14.25px;" class="">On Wed, Jul 20, 2016 at 11:58 PM, Xiaodi Wu via swift-evolution <</span><br style="font-size: 14.25px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-size: 14.25px;" class="">swift-evolution@swift.org</a><span style="font-size: 14.25px;" class="">> wrote:</span><br style="font-size: 14.25px;" class=""><br style="font-size: 14.25px;" class=""><blockquote type="cite" style="font-size: 14.25px;" class="">I'd run this by someone who actually knows math, but afaik there are<br class="">finitely many empty strings in any given string.<br class=""><br class="">How many e's are in any given string? (Ignoring Unicode issues for now,)<br class="">for each index in the string's indices, form a substring one character in<br class="">length starting at that index and compare the value of that substring to e.<br class=""><br class="">How many empty strings are in any given string? For each index in the<br class="">string's indices, form a substring zero characters in length starting at<br class="">that index and compare the value of that substring to an empty string.<br class=""><br class=""><br class=""><br class="">On Wed, Jul 20, 2016 at 17:35 Guillaume Lessard <<br class=""><a href="mailto:glessard@tffenterprises.com" class="">glessard@tffenterprises.com</a>> wrote:<br class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class="">On 20 juil. 2016, at 14:21, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> wrote:<br class=""><br class="">Doesn't your second argument undermine your first? If it's a trivial<br class=""></blockquote>solution and one rarely ever considers empty strings when invoking<br class="">`hasPrefix`, then returning the technically correct result must be a<br class="">trivial departure in behavior.<br class=""><br class="">I specifically used an example where the trivial solution (y=0 instead of<br class="">y=exp(x)) is a pitfall.<br class=""><br class="">How many empty strings are contained in any given string?<br class="">If the answer is infinitely many, it sounds like a pitfall to me.<br class=""><br class="">Cheers,<br class="">Guillaume Lessard<br class=""><br class=""><br class=""></blockquote>_______________________________________________</blockquote></blockquote></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br 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><br class=""></div></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>