bool :dict-contains ( array $ARR , mixed $ELEM , … )
bool :dict-contains ( dict $DICT , mixed $ELEM , … )
bool :arr-contains ( array $ARR , mixed $ELEM , … )
bool :arr-contains ( dict $DICT , mixed $ELEM , … )
Checks whether the given element is present in array/dictionary, using loose comparison (:eq
).
Can be passed multiple values; will yield TRUE only if all elements are present.
It is recommended the array/dictionary is passed by reference, as this saves the work of copying the structure.
# :arr-contains example. !fun :rand-arr $NUM :set &ARR :arr !while $NUM :set &ARR[:sub &NUM i1] :random i100 !done :return &ARR !nuf :set &A :rand-arr i10 !if :arr-contains &A i50 :writeln s'Yay, 50 is in the random array!' !else :writeln s'How sad, 50 was not rolled this time.' !fi
wikipage modified on 2014/0601/2316