You are viewing a single comment's thread. Return to all comments →
public PerformOperation is_odd(){ return n -> (n%2 != 0); } public PerformOperation is_prime(){ return n -> IntStream.rangeClosed(2, (int) Math.sqrt(n)) .noneMatch(i -> n%i == 0); } public PerformOperation is_palindrome(){ return n -> IntStream.iterate(n, e -> e/10 ) .limit(11) .filter(f -> f>0) .map(e -> e%10) .reduce(0, (c,e)->c*10+e) == n; }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Lambda Expressions
You are viewing a single comment's thread. Return to all comments →