# How to efficiently identify if integer is in wave? Hello,

I have wave of integers (16 bit, random order positive integers) and I need to know if a specific integer value is already in that wave.

First I wrote function which iterates over the wave, but I nearly felt ashamed when I saw the result.

Then I used extract for points which match that integer value and checked the extracted wave length. Still, had to write user function for that.

I still feel there could be some single line solution to this simple issue which is escaping me. Any suggestions?

Thanks a lot!

In the event that your wave contains more than one instance of the integer value (say i_value) you can write in IP9 the following command:

`MatrixOP/o/p=1 aa=zapNaNs(replace(equal(myWave,i_value)*IndexRows(myWave),0,nan))`

For example:

make/b/u ddd=trunc(128*sin(2*pi*x/40))
MatrixOP/o/p=1 aa=zapNaNs(replace(equal(ddd,58)*IndexRows(ddd),0,nan))
aa={3,17,43,57,83,97,123}  // index points where 58 is found.

In the case of SP/DP data one needs to take into account some tolerance value.  Here is an example:

Redimension/S ddd
ddd+=enoise(0.1)
Variable tol=0.15
Variable value=58
MatrixOP/o/p=1 aa=zapNaNs(replace(greater(tol,abs(ddd-value))*IndexRows(ddd),0,nan))
aa={3,17,43,57,83,97,123}

Don't forget that in IP8 and later, FindValue has a /UOFV flag which will do the search for the value in multiple threads. If you only care if you have a given value in the wave at least one time, this flag might be appropriate if you're not already running the code in threads.