Numeric Conditions

even(): Check if number is even

Returns a condition that checks if a number is even.

Stream.of([1, 2, 3, 4, 5] \
    .filter(even()) \
    .for_each(print) # 2, 4

odd(): Check if number is odd

Returns a condition that checks if a number is odd.

Stream.of([1, 2, 3, 4, 5] \
    .filter(odd()) \
    .for_each(print) # 1, 3, 5

positive(): Check if number is positive

Returns a condition that checks if a number is positive.

Stream.of([-1, 0, 2, -3, 4] \
    .filter(positive()) \
    .for_each(print) # 2, 4

negative(): Check if number is negative

Returns a condition that checks if a number is negative.

zero(): Check if number is zero

Returns a condition that checks if a number is zero.

non_zero(): Check if number is non-zero

Returns a condition that checks if a number is non-zero.

greater_than(n): Check if number is greater than a given value

Returns a condition that checks if a number is greater than a given value.

greater_than_or_equal(n): Check if number is greater than or equal to a given value

Returns a condition that checks if a number is greater than or equal to a given value.

less_than(n): Check if number is less than a given value

Returns a condition that checks if a number is less than a given value.

less_than_or_equal(n): Check if number is less than or equal to a given value

Returns a condition that checks if a number is less than or equal to a given value.

between(minimum, maximum): Check if number is between two given values

Returns a condition that checks if a number is between two given values (inclusive).

not_between(minimum, maximum): Check if number is not between two given values

Returns a condition that checks if a number is not between two given values (inclusive).

equal_to(n): Check if number is equal to a given value

Returns a condition that checks if a number is equal to a given value.

not_equal_to(n): Check if number is not equal to a given value

Returns a condition that checks if a number is not equal to a given value.

multiple_of(n): Check if number is a multiple of a given value

Returns a condition that checks if a number is a multiple of a given value.

not_multiple_of(n): Check if number is not a multiple of a given value

Returns a condition that checks if a number is not a multiple of a given value.

divisor_of(n): Check if number is a divisor of a given value

Returns a condition that checks if a number is a divisor of a given value.

not_divisor_of(n): Check if number is not a divisor of a given value

Returns a condition that checks if a number is not a divisor of a given value.

prime(): Check if number is prime

Returns a condition that checks if a number is prime.

not_prime(): Check if number is not prime

Returns a condition that checks if a number is not prime.

perfect_square(): Check if number is a perfect square

Returns a condition that checks if a number is a perfect square.

not_perfect_square(): Check if number is not a perfect square

Returns a condition that checks if a number is not a perfect square.

perfect_cube(): Check if number is a perfect cube

Returns a condition that checks if a number is a perfect cube.

not_perfect_cube(): Check if number is not a perfect cube

Returns a condition that checks if a number is not a perfect cube.

perfect_power(): Check if number is a perfect power

Returns a condition that checks if a number is a perfect power.

not_perfect_power(): Check if number is not a perfect power

Returns a condition that checks if a number is not a perfect power.

palindrome(): Check if number is a palindrome

Returns a condition that checks if a number is a palindrome.

not_palindrome(): Check if number is not a palindrome

Returns a condition that checks if a number is not a palindrome.

armstrong(): Check if number is an Armstrong number

Returns a condition that checks if a number is an Armstrong number.

not_armstrong(): Check if number is not an Armstrong number

Returns a condition that checks if a number is not an Armstrong number.

narcissistic(): Check if number is a narcissistic number

Returns a condition that checks if a number is a narciss

istic number.

not_narcissistic(): Check if number is not a narcissistic number

Returns a condition that checks if a number is not a narcissistic number.

happy(): Check if number is a happy number

Returns a condition that checks if a number is a happy number.

sad(): Check if number is a sad number

Returns a condition that checks if a number is a sad number.

abundant(): Check if number is an abundant number

Returns a condition that checks if a number is an abundant number.

not_abundant(): Check if number is not an abundant number

Returns a condition that checks if a number is not an abundant number.

deficient(): Check if number is a deficient number

Returns a condition that checks if a number is a deficient number.

not_deficient(): Check if number is not a deficient number

Returns a condition that checks if a number is not a deficient number.

perfect(): Check if number is a perfect number

Returns a condition that checks if a number is a perfect number.

not_perfect(): Check if number is not a perfect number

Returns a condition that checks if a number is not a perfect number.

Last updated

Was this helpful?