even, odd, whole

Prev Next

Function Names

even, odd, whole

Description

whole returns true if the number is a whole number
even returns true if the number is a whole number and even
odd returns true if the number is a whole number and odd


Non-numeric values (including dates) are passed through without modifications. This is particularly suitable in combination with vectorization in order to pass through blank contents, explanatory text, etc.

Vectorization: This function supports vectorization in the 1st function parameter. Instead of providing a single value, you can provide a set or even a nested set which contain multiple values. The function will then process every value and its return value contains a corresponding set containing all results.

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter

Parameter count

1

Parameters

No.TypeDescription
1
input
numeral
set
Value

Input value or a set containing numerals to check (vectorization).

Return value

TypeDescription
boolean
set
Result

true if criteria is met. Multiple values are returned in a set if vectorization has been made use of.

Exceptions

Value provided is not a numeral

Examples

               a[] = { 1, 1.5, 2, 3, 4. -1, -1.5, -2 };
               for all( a[], p[] )
               {
                       print(p[],": is ");
                       if (even (p[])) print ("even, ");
                       if (odd  (p[])) print ("odd, ");
                       if (whole(p[])) print ("whole, ");
                       echo;
               }
               echo("Vectorization example: ", whole(a[]) );

Output

1: is odd, whole,
1.5: is
2: is even, whole,
3: is odd, whole,
3: is odd, whole,
-1.5: is
-2: is even, whole,
Vectorization example: {true,false,true,true,true,false,true}
Try it yourself: Open LIB_Function_even.b4p in B4P_Examples.zip. Decompress before use.