What is a predicate?

A predicate function is "a function that either returns TRUE or FALSE." While a predicate functional "takes a vector and a predicate function and do something useful."***

In other words, the predicate functionals take in .x, which is a vector, a dataframe, or a list, and test the predicate on every element of .x. For example, you can test if every element is numeric with the is.numeric() predicate from R-Base, or if the mean of some elements is under 5 with this mapper: ~mean(.x) < 5.

Which of these functions is NOT a predicate?

This exercise is part of the course

Intermediate Functional Programming with purrr

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise