limit
This function limits numeric of any type within a lower and upper boundary. Supported types are numeral, strings, dates and,
even if less meaningful, booleans. The types in all 3 function parameters must be consistent.
No limitations will be applied if the lower boundary is greater than the upper boundary. If the lower and upper bounaries are
equal, then the result will equal to the boundary values.
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.
Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter
3
No. | Type | Description |
---|---|---|
1 input |
valid types set |
Value(s) to limit The values or set of values (if vectorization is applied) will be limited to the lower and upper boundaries provided in the next function parameters. |
2 input |
valid types except sets | lower boundary This value reflects the lower boundary. Sets are not allowed here. |
3 input |
valid types except sets | upper boundary This value reflects the upper boundary. Sets are not allowed here. |
Type | Description |
---|---|
valid types set |
Result Calculated result. If vectorization is used, then a set containing the results is returned. |
Attempting to work with incompatible types, e.g. numerals with strings
a[] = { 0, 2, 4, 6, 8, 10, 12 };
echo( limit( a[], 3, 7 ) ); // Limitatino with 3 and 7
echo( limit( a[], 7, 7 ) ); // All results = 7
echo( limit( a[], 7, 3 ) ); // No limitations
echo;
a[] = { Ape, Bee, Cat, Dog, Elk, Fly, Gnu, Hen };
echo( limit( a[], Cow, Fox ) ); // Limitation
echo( limit( a[], Eel, Eel ) ); // All results = 7
echo( limit( a[], Eel, Cow ) ); // No limitations
echo;
a[] = date( { 01.01.2024, 01.04.2024, 01.07.2024, 01.10.2024, 31.12.2024 } );
echo( limit( a[], date(28.02.2024), date(01.09.2024) ) ); // Limitation to specifeid dates
echo( limit( a[], date(14.07.2024), date(14.07.2024) ) ); // All results set to limit values
echo( limit( a[], date(01.09.2024), date(28.02.2024) ) ); // No Limitation
echo;
a[] = { false, true };
echo( limit( a[], false, true ) ); // Limitation
echo( limit( a[], true, true ) ); // All results = true
echo( limit( a[], true, false ) ); // No limitations
{3,3,4,6,7,7,7}
{7,7,7,7,7,7,7}
{0,2,4,6,8,10,12}
{'Cow','Cow','Cow','Dog','Elk','Fly','Fox','Fox'}
{'Eel','Eel','Eel','Eel','Eel','Eel','Eel','Eel'}
{'Ape','Bee','Cat','Dog','Elk','Fly','Gnu','Hen'}
{'2024-02-28','2024-04-01','2024-07-01','2024-09-01','2024-09-01'}
{'2024-07-14','2024-07-14','2024-07-14','2024-07-14','2024-07-14'}
{'2024-01-01','2024-04-01','2024-07-01','2024-10-01','2024-12-31'}
{false,true}
{true,true}
{false,true}
min
max
min 123
max 123
min numeral
max numeral
min abc
max abc
min string
max string
min abc ignore case
max abc ignore case
min string ignore case
max string ignore case