Clojure - Higher Order Functions


Advertisements

Higher-order functions (HOFs) are functions that take other functions as arguments. HOFs are an important functional programming technique and are quite commonly used in Clojure. One example of an HOF is a function that takes a function and a collection and returns a collection of elements that satisfy a condition (a predicate). In Clojure, this function is called clojure.core/filter

Example

Following is an example code of the higher order function.

(filter even? (range 0 10))

Output

The above program produces the following output.

(0 2 4 6 8)
clojure_functions.htm
Advertisements