<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le dim. 10 févr. 2019 à 20:16, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><br><br><div id="gmail-m_8430060193723759601AppleMailSignature" dir="ltr"><span style="background-color:rgba(255,255,255,0)">_,,,^..^,,,_ (phone)</span></div><div dir="ltr"><br>On Feb 10, 2019, at 6:27 AM, Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div>does anyone really need a fuzzy Interval indexOf:startingAt: ?</div><div>Right now, we have this:</div><div><div><br></div><div>    ((0.1 to: 0.9 by: 0.1) indexOf: 0.3) = 3.</div></div><div>    ((0.1 to: 0.9 by: 0.1) includes: 0.3) = true.</div><br><div>While this can sound nice, I don't think it is.</div><div>No other collection behaves like that.<br></div><div><br><div>    ((0.1 to: 0.9 by: 0.1) asArray includes: 0.3) = false.<br><div>    ((0.1 to: 0.9 by: 0.1) asSet includes: 0.3) = false.</div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div><br></div><span style="background-color:rgba(255,255,255,0)">What if instead we added a range numeric type?  Then we could write something like</span><div><br></div><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font color="#000000"><span style="background-color:rgba(255,255,255,0)">((0.1 to: 0.9 by: 0.1) asArray includes: (0.3 plusOrMinus: 0.001)) = true.</span></font></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>You can even use a nice binary operator 0.3 +/- 0.001 :)</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><div><br></div>NumericRange would be instantiated via <span style="background-color:rgba(255,255,255,0)">plusOrMinus: & from:to:, and implement interval arithmetic and interval comparison.  So = would be</span></div><div><br></div><div>= aMagnitude</div><div>    ^<span style="background-color:rgba(255,255,255,0)">aMagnitude between: start and stop</span></div><div><br></div><div>and <span style="background-color:rgba(255,255,255,0)">NumericRange would itself use its midpoint for comparisons against magnitudes.  It would presumably not be a magnitude itself though, so that two NumericRanges would be equal only if they represented the same range, not had the same midpoint.</span></div></div></blockquote><div><br></div><div>All these solutions make = not transitive...</div><div>    a = b && (b = c) ==> (a = c)</div><div><br></div><div>So if we want interval arithmetic we'd rather use another set of selectors for achieving this fuzzyfication...</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><br><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><div><br></div></div><div>Even Interval itself does not behave consitently:</div><div><br>    ((0.1 to: 0.9 by: 0.1) lastIndexOf: 0.3) = 0.<br></div><div>    ((0.1 to: 0.9 by: 0.1) occurrencesOf: 0.3) = 0.<br>    ((0.1 to: 0.9 by: 0.1) copyWithout: 0.3) = #(0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7000000000000001 0.8 0.9).</div><div><br></div><div>We have ScaledDecimal and Fraction which are less surprising, so IMO we should better use them when we really want to play with equality rather than trying to cheat with Float equality.<br></div><div><br></div></div></div></div></div></div>
</div></blockquote><blockquote type="cite"><div dir="ltr"><span></span><br></div></blockquote></div></div><br>
</blockquote></div></div>