[Thread Prev][Thread Next][Index]

Re: [ferret_users] existence of elements in array



And other thing which you asked, as far as I know there is no "CASE / SWITCH" statement in Ferret, you have to manage with IF-ELIF-ELSE clause only, if you have PyFerret then inside external function you can use switch statement.

Regards,
Akshay Hegde,
Data and Information,
CSIR-NIO
https://about.me/akshay.k.hegde



On Fri, Jun 16, 2017 at 6:04 PM, Marco van Hulten <Marco.Hulten@xxxxxx> wrote:
Hello Akshay,

On 16 Jun 17:45 Akshay Hegde wrote:
> 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?

Thank you, this works for number arrays!

I want to do the same for arrays of strings. This function doesn't
take strings, but I found a very similar function for that:

yes? let ss = {"a", "b", "c"};
yes? list IS_ELEMENT_OF_STR(ss, "c")
VARIABLE : IS_ELEMENT_OF_STR(SS, "c")
X : 1
1.000
yes?

Fantastic.

- Marco


[Thread Prev][Thread Next][Index]