HP Forums
Function or operator to test list membership - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Function or operator to test list membership (/thread-5556.html)



Function or operator to test list membership - sbergman27 - 01-19-2016 03:28 PM

I'm looking for a quick way to check to see if an integer is an element of a list. Maybe I'm just searching for the wrong terms in the Prime User Guide. But I haven't found a fast way to do it. Is "intersect" my best bet?


RE: Function or operator to test list membership - Didier Lachieze - 01-19-2016 03:41 PM

You can use:
POS(list, element)

Returns the position of an element within a list. A value of 0 is returned if there is no occurrence of the specified element.

Example:
POS ({3,7,12,19},12) returns 3


RE: Function or operator to test list membership - sbergman27 - 01-22-2016 04:13 AM

Thank you.