AnsweredAssumed Answered

VRF-Checking if a number is contained within an array ..

Question asked by VRFuser on Mar 17, 1998
The proposed solutions does not feel straight forward to me.
I would prefer a more generalized solution.
What about this one:

given the array and the lookupvalue
1. the formula
   abs((array-min(array))-(lookupvalue-min(array)))
returns an array with as minimum value the array element which was
originally the closest to the lookupvalue.
In case of an exact match this value will be zero.

2. the formula
   ramp(totsize(a), 0, totsize(a)-1)
generates a nice index

3. put these two together with a built-coord object

4. sort this coord-array

5. the check:
if the first element is zero, hit! with its X-value indicating the
corresponding index.

This all of course could be combined into one single formula.

> James Atkin wrote:
> >
> > Is there a function to check if a number is part of an array of x numbers.
> > i.e. Is the number 3 contained within an array of 10 integers ?
> >
> > Thanks
> >
> > James
> >
> > (James.Atkin@Phase.Com)
> >
> >
>
With kind regards,
  Johannes Mulder           
  Philips Electron Optics            tel +31 40 2766867
  Building AAE-room 21               fax +31 40 2766820
  P.O.B. 218                  
  5600 MD ACHT, the Netherlands

Outcomes