How-to articles, tricks, and solutions about FUNCTIONAL-PROGRAMMING

Functional style of Java 8's Optional.ifPresent and if-not-Present?

The ifPresent() and ifPresentOrElse() methods of the Optional class in Java 8 provide a functional style way to perform different actions depending on whether the Optional object is empty or contains a value.

List comprehension vs. lambda + filter

List comprehension and the combination of lambda functions and the filter() function in Python are both used to filter a list and return a new list with only the elements that satisfy a certain condition.