I'm confused by the following trivial code:
{Range[0, 1, .1][[8]]} === {.7}
gives True
MemberQ[{.7}, .7]
gives True, but
MemberQ[{Range[0, 1, .1][[8]]}, .7]
gives False. Huh? What am I missing?
I'm confused by the following trivial code:
{Range[0, 1, .1][[8]]} === {.7}
gives True
MemberQ[{.7}, .7]
gives True, but
MemberQ[{Range[0, 1, .1][[8]]}, .7]
gives False. Huh? What am I missing?
{Range[0, 1, .1][[8]], .7} // InputFormought to be enlightening. Moral lesson is that you don't do such pattern matches on inexact numbers. – J. M.'s missing motivation Aug 06 '17 at 12:53Internal`$SameQTolerance(orInternal`$EqualToleranceif you had used==). See e.g. this. – J. M.'s missing motivation Aug 06 '17 at 12:59