filter function is a commonly-used
It takes a function as an argument.
filter function works as its name implies.
It filters out values in a sequence that don’t meet the given condition.
To perform this filtering,
filter takes a function and a sequence for its arguments.
The function given to the
filter must return a truthy value, and is called a predicate function.
The syntax is:
(filter pred coll)
Let’s see the examples:
We can use an
anonymous function for filtering.
The next example defines a flower list as a map (data structure) with simple keys and colors as values.
From this map, the code below selects yellows or pinks.
We can also use the function we defined for filtering. The third example selects palindromic numbers between 1000 and 4999. (see palindrome: http://en.wikipedia.org/wiki/Palindromic_number)
Introduction to Clojure, filter and remove
Clojure from the ground up: sequences, Subsequences
Clojure for the Brave and True, Core Functions in Depth