Numeric Conditions
even(): Check if number is even
even(): Check if number is evenReturns a condition that checks if a number is even.
Stream.of([1, 2, 3, 4, 5] \
.filter(even()) \
.for_each(print) # 2, 4odd(): Check if number is odd
odd(): Check if number is oddReturns a condition that checks if a number is odd.
Stream.of([1, 2, 3, 4, 5] \
.filter(odd()) \
.for_each(print) # 1, 3, 5positive(): Check if number is positive
positive(): Check if number is positiveReturns a condition that checks if a number is positive.
Stream.of([-1, 0, 2, -3, 4] \
.filter(positive()) \
.for_each(print) # 2, 4negative(): Check if number is negative
negative(): Check if number is negativeReturns a condition that checks if a number is negative.
Stream.of([-1, 0, 2, -3, 4] \
.filter(negative()) \
.for_each(print) # -1, -3zero(): Check if number is zero
zero(): Check if number is zeroReturns a condition that checks if a number is zero.
Stream.of([-1, 0, 2, -3, 4] \
.filter(zero()) \
.for_each(print) # 0non_zero(): Check if number is non-zero
non_zero(): Check if number is non-zeroReturns a condition that checks if a number is non-zero.
Stream.of([-1, 0, 2, -3, 4] \
.filter(non_zero()) \
.for_each(print) # -1, 2, -3, 4greater_than(n): Check if number is greater than a given value
greater_than(n): Check if number is greater than a given valueReturns a condition that checks if a number is greater than a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(greater_than(3)) \
.for_each(print) # 4, 5greater_than_or_equal(n): Check if number is greater than or equal to a given value
greater_than_or_equal(n): Check if number is greater than or equal to a given valueReturns a condition that checks if a number is greater than or equal to a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(greater_than_or_equal(3)) \
.for_each(print) # 3, 4, 5less_than(n): Check if number is less than a given value
less_than(n): Check if number is less than a given valueReturns a condition that checks if a number is less than a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(less_than(3)) \
.for_each(print) # 1, 2less_than_or_equal(n): Check if number is less than or equal to a given value
less_than_or_equal(n): Check if number is less than or equal to a given valueReturns a condition that checks if a number is less than or equal to a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(less_than_or_equal(3)) \
.for_each(print) # 1, 2, 3between(minimum, maximum): Check if number is between two given values
between(minimum, maximum): Check if number is between two given valuesReturns a condition that checks if a number is between two given values (inclusive).
Stream.of([1, 2, 3, 4, 5] \
.filter(between(2, 4)) \
.for_each(print) # 2, 3, 4not_between(minimum, maximum): Check if number is not between two given values
not_between(minimum, maximum): Check if number is not between two given valuesReturns a condition that checks if a number is not between two given values (inclusive).
Stream.of([1, 2, 3, 4, 5] \
.filter(not_between(2, 4)) \
.for_each(print) # 1, 5equal_to(n): Check if number is equal to a given value
equal_to(n): Check if number is equal to a given valueReturns a condition that checks if a number is equal to a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(equal_to(3)) \
.for_each(print) # 3not_equal_to(n): Check if number is not equal to a given value
not_equal_to(n): Check if number is not equal to a given valueReturns a condition that checks if a number is not equal to a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(not_equal_to(3)) \
.for_each(print) # 1, 2, 4, 5multiple_of(n): Check if number is a multiple of a given value
multiple_of(n): Check if number is a multiple of a given valueReturns a condition that checks if a number is a multiple of a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(multiple_of(2)) \
.for_each(print) # 2, 4not_multiple_of(n): Check if number is not a multiple of a given value
not_multiple_of(n): Check if number is not a multiple of a given valueReturns a condition that checks if a number is not a multiple of a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(not_multiple_of(2)) \
.for_each(print) # 1, 3, 5divisor_of(n): Check if number is a divisor of a given value
divisor_of(n): Check if number is a divisor of a given valueReturns a condition that checks if a number is a divisor of a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(divisor_of(12)) \
.for_each(print) # 1, 2, 3, 4, 6, 12not_divisor_of(n): Check if number is not a divisor of a given value
not_divisor_of(n): Check if number is not a divisor of a given valueReturns a condition that checks if a number is not a divisor of a given value.
Stream.of([1, 2, 3, 4, 5] \
.filter(not_divisor_of(12)) \
.for_each(print) # 5prime(): Check if number is prime
prime(): Check if number is primeReturns a condition that checks if a number is prime.
Stream.of([1, 2, 3, 4, 5] \
.filter(prime()) \
.for_each(print) # 2, 3, 5not_prime(): Check if number is not prime
not_prime(): Check if number is not primeReturns a condition that checks if a number is not prime.
Stream.of([1, 2, 3, 4, 5]
\
.filter(not_prime()) \
.for_each(print) # 1, 4perfect_square(): Check if number is a perfect square
perfect_square(): Check if number is a perfect squareReturns a condition that checks if a number is a perfect square.
Stream.of([1, 2, 3, 4, 5] \
.filter(perfect_square()) \
.for_each(print) # 1, 4not_perfect_square(): Check if number is not a perfect square
not_perfect_square(): Check if number is not a perfect squareReturns a condition that checks if a number is not a perfect square.
Stream.of([1, 2, 3, 4, 5] \
.filter(not_perfect_square()) \
.for_each(print) # 2, 3, 5perfect_cube(): Check if number is a perfect cube
perfect_cube(): Check if number is a perfect cubeReturns a condition that checks if a number is a perfect cube.
Stream.of([1, 2, 3, 4, 5] \
.filter(perfect_cube()) \
.for_each(print) # 1not_perfect_cube(): Check if number is not a perfect cube
not_perfect_cube(): Check if number is not a perfect cubeReturns a condition that checks if a number is not a perfect cube.
Stream.of([1, 2, 3, 4, 5] \
.filter(not_perfect_cube()) \
.for_each(print) # 2, 3, 4, 5perfect_power(): Check if number is a perfect power
perfect_power(): Check if number is a perfect powerReturns a condition that checks if a number is a perfect power.
Stream.of([1, 2, 3, 4, 5] \
.filter(perfect_power()) \
.for_each(print) # 1, 4not_perfect_power(): Check if number is not a perfect power
not_perfect_power(): Check if number is not a perfect powerReturns a condition that checks if a number is not a perfect power.
Stream.of([1, 2, 3, 4, 5] \
.filter(not_perfect_power()) \
.for_each(print) # 2, 3, 5palindrome(): Check if number is a palindrome
palindrome(): Check if number is a palindromeReturns a condition that checks if a number is a palindrome.
Stream.of([12321, 456, 78987] \
.filter(palindrome()) \
.for_each(print) # 12321, 78987not_palindrome(): Check if number is not a palindrome
not_palindrome(): Check if number is not a palindromeReturns a condition that checks if a number is not a palindrome.
Stream.of([12321, 456, 78987] \
.filter(not_palindrome()) \
.for_each(print) # 456armstrong(): Check if number is an Armstrong number
armstrong(): Check if number is an Armstrong numberReturns a condition that checks if a number is an Armstrong number.
Stream.of([153, 370, 9474] \
.filter(armstrong()) \
.for_each(print) # 153, 370, 9474not_armstrong(): Check if number is not an Armstrong number
not_armstrong(): Check if number is not an Armstrong numberReturns a condition that checks if a number is not an Armstrong number.
Stream.of([153, 370, 9474] \
.filter(not_armstrong()) \
.for_each(print) # Nonenarcissistic(): Check if number is a narcissistic number
narcissistic(): Check if number is a narcissistic numberReturns a condition that checks if a number is a narciss
istic number.
Stream.of([153, 370, 9474] \
.filter(narcissistic()) \
.for_each(print) # 153, 370, 9474not_narcissistic(): Check if number is not a narcissistic number
not_narcissistic(): Check if number is not a narcissistic numberReturns a condition that checks if a number is not a narcissistic number.
Stream.of([153, 370, 9474] \
.filter(not_narcissistic()) \
.for_each(print) # Nonehappy(): Check if number is a happy number
happy(): Check if number is a happy numberReturns a condition that checks if a number is a happy number.
Stream.of([19, 32, 86] \
.filter(happy()) \
.for_each(print) # 19, 32sad(): Check if number is a sad number
sad(): Check if number is a sad numberReturns a condition that checks if a number is a sad number.
Stream.of([19, 32, 86] \
.filter(sad()) \
.for_each(print) # 86abundant(): Check if number is an abundant number
abundant(): Check if number is an abundant numberReturns a condition that checks if a number is an abundant number.
Stream.of([12, 16, 28] \
.filter(abundant()) \
.for_each(print) # 12, 16, 28not_abundant(): Check if number is not an abundant number
not_abundant(): Check if number is not an abundant numberReturns a condition that checks if a number is not an abundant number.
Stream.of([12, 16, 28] \
.filter(not_abundant()) \
.for_each(print) # Nonedeficient(): Check if number is a deficient number
deficient(): Check if number is a deficient numberReturns a condition that checks if a number is a deficient number.
Stream.of([12, 16, 28] \
.filter(deficient()) \
.for_each(print) # Nonenot_deficient(): Check if number is not a deficient number
not_deficient(): Check if number is not a deficient numberReturns a condition that checks if a number is not a deficient number.
Stream.of([12, 16, 28] \
.filter(not_deficient()) \
.for_each(print) # 12, 16, 28perfect(): Check if number is a perfect number
perfect(): Check if number is a perfect numberReturns a condition that checks if a number is a perfect number.
Stream.of([6, 28, 496] \
.filter(perfect()) \
.for_each(print) # 6, 28, 496not_perfect(): Check if number is not a perfect number
not_perfect(): Check if number is not a perfect numberReturns a condition that checks if a number is not a perfect number.
Stream.of([6, 28, 496] \
.filter(not_perfect()) \
.for_each(print) # NoneLast updated
Was this helpful?