<div dir="ltr">For consistency, the name for this function would be `isSuperset(of:)`, and it would be equally interesting to have `isStrictSuperset(of:)`, `isSubset(of:)`, `isStrictSubset(of:)` and `isDisjoint(with:)`--all currently available for types that conform to `SetAlgebra`.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 8, 2017 at 9:40 PM, Yuta Koshizawa via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<br><br>Recently I needed to implement `contains` methods to check if a range contains another range. I think those are basic operations and suitable for the standard library.<br><br>Although it may seem easy to implement such `contains` methods whenever we need them, their precise specifications are too complicated to do so.<br><br>e.g.<br><br>let a: ClosedRange&lt;Int&gt; = 2...7<br>a.contains(3...5) // `true`<br>a.contains(3...7) // also `true`<br>a.contains(3..&lt;8) // still `true` because all values contained in `3..&lt;8` are also in `a`<br>a.contains(3..&lt;9) // `false`<br><br>let b: ClosedRange&lt;Float&gt; = 2...7<br>b.contains(3...5) // `true`<br>b.contains(3...7) // `true`<br>b.contains(3..&lt;8) // `false` because { x | 7.0 &lt; x &lt; 8.0 } is not contained in `a`<br><br>let c: Range&lt;Float&gt; = 2..&lt;7<br>c.contains(3...5) // `true`<br>c.contains(3..&lt;7) // `true`<br>c.contains(3...7) // `false` because 7.0 is not contained in `a`<br><br>My experimental implementation is here:<br><a href="https://github.com/koher/range-contains" target="_blank">https://github.com/koher/<wbr>range-contains</a><br>(Currently does not support one-sided ranges)<br><br>What are your thoughts about them?<br><br>--<br>Yuta<br></div>
<br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div>