[Thread Prev][Thread Next][Index]

Re: [ferret_users] existence of elements in array



Hi Marco!

Make use of "IS_ELEMENT_OF" function

[root@localhost tmp]# f
NOAA/PMEL TMAP
FERRET v6.96
Linux 2.6.32-573.7.1.el6.x86_64 64-bit - 12/02/15
16-Jun-17 17:42

yes? let aa = {1, 2, 3};
yes? list IS_ELEMENT_OF(aa, 3)
VARIABLE : IS_ELEMENT_OF(AA, 3)
X : 1
1.000
yes? list IS_ELEMENT_OF(aa, 35)
VARIABLE : IS_ELEMENT_OF(AA, 35)
X : 1
0.0000
yes? IF `IS_ELEMENT_OF(aa, 35) NE 0` THEN
!-> IF 0 THEN
yes? say 'exists'
yes? ELSE
yes? say 'does not exists'
'does not exists'
yes? ENDIF
yes?



Regards,
Akshay Hegde,
Data and Information,


On Fri, Jun 16, 2017 at 5:01 PM, Marco van Hulten <Marco.Hulten@xxxxxx> wrote:
Hello,

I would like to see if certain elements are in an array. Suppose I
have and array aa = {1, 2, 3} , I want to check if a number is in the
array (pseudo-ferret code):

if `3 \in aa` then say "3 is in aa"
if `7 \in aa` then say "7 is in aa"

How would you write out the \in in Ferret?

Or, using fewer characters, a case statement like (pseudo-bash code):

case bb in
3) say "3 is in aa"
7) say "7 is in aa"

Is there any equivalent in classical Ferret?

In the end I want to do this with an array of strings.

- Marco


[Thread Prev][Thread Next][Index]