CommencerCommencer gratuitement

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?

Cet exercice fait partie du cours

Intermediate Functional Programming with purrr

Afficher le cours

Exercice interactif pratique

Passez de la théorie à la pratique avec l’un de nos exercices interactifs

Commencer l’exercice