Comparisons

Predicate factories for filter chains and control flow. Bind a comparison once, reuse it against many values. Combine predicates with AND / OR / NOT to build richer conditions without repeating yourself.

Equality and ordering

$isFoo    = C\isEqualTo('foo');
$isFoo('foo');     // true
$isFoo('bar');     // false

$over18   = C\isGreaterThanOrEqualTo(18);
$over18(21);       // true
$over18(17);       // false

$inPalette = C\isEqualIn(['red', 'green', 'blue']);
$inPalette('red');    // true
$inPalette('yellow'); // false

Also: isNotEqualTo, isGreaterThan, isLessThan, isLessThanOrEqualTo.

Type and truthiness

$isString = C\isScalar('string');     // curried — binds the gettype() name
$isString('hello');   // true
$isString(42);        // false

C\isNumber(3.14);     // true     — direct call (int or float only)
C\isNumber('3.14');   // false    — stricter than is_numeric()
C\notEmpty([]);       // false
C\notEmpty('hello');  // true

Also: isTrue, isFalse, sameScalar, allTrue, anyTrue.

Combining predicates

$isStringLongEnough = C\groupAnd('is_string', fn($s) => strlen($s) >= 3);
$isStringLongEnough('ok');    // false
$isStringLongEnough('hello'); // true

$isNotZero = C\not(C\isEqualTo(0));
$isNotZero(0);   // false
$isNotZero(5);   // true

any / all are aliases of groupOr / groupAnd with a more natural reading.

Deep-dive examples

Comparisons Functions