filter

(filter f coll)

The filter function takes 2 arguments :

  • f: a function that takes one argument x and returns TRUE or FALSE 1
  • coll: a collection of items

filter returns a sequence of items from the collection for which f returns TRUE (it’s the opposite of remove).

In the above animation, f returns TRUE when the item is a triangle or when it is blue.

filter


  1. such function is called a predicate ↩︎