The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
==/EQ() and approx()
10-13-2016, 07:48 AM (This post was last modified: 10-13-2016 07:54 AM by TravisE.)
Post: #1
==/EQ() and approx()
I expect to write some code where I intend to test the literal contents of a variable or value to see whether it is a list and, if it is, whether it contains a specific sequence of values. Since == does an element-by-element comparison, and I want to do a full comparison, EQ() would appear to be the proper function to use.

But I find that == and EQ() are annoyingly picky and error out if the types of the objects do not match. (For my purposes, I'd much rather it simply return 0 instead, since logically, they are not equivalent.)

While fooling around, though, I discovered that wrapping an == test comparing a list and any other object inside approx() seems to do what I want. It appears to does a literal list comparison like EQ(), returning 1 only if the two lists are exactly the same, 0 if they aren't, and 0 instead of an error if the object types are not the same.

But this seems kind of strange and counterintuitive to me—what do equivalence and approx() have in common? Is this actually doing what I think it is? Can I rely on this behavior? I wasn't immediately able to find any reference to this in the on-calc help.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
==/EQ() and approx() - TravisE - 10-13-2016 07:48 AM
RE: ==/EQ() and approx() - Tim Wessman - 10-13-2016, 05:56 PM
RE: ==/EQ() and approx() - Tim Wessman - 10-13-2016, 06:03 PM
RE: ==/EQ() and approx() - TravisE - 10-14-2016, 04:43 AM



User(s) browsing this thread: 2 Guest(s)