Assumes that if a predicate on the left is FALSE
,
the succeeding one on the right will also be FALSE
and can thus be skipped.
accumulate_pred_trans(.z, .lf, ...)
transitively(.p, ...)
.z | A list or atomic vector. |
---|---|
.lf | A list of predicate functions. |
... | Additional named arguments to |
.p | A predicate function. |
A dataframe of logical vectors, one column per predicate function.
Skipped predicate tests return a NA
.
When checking data (such as bibliometric metadata) against several criteria of compliance (such as uniqueness, syntax), two conditions can hold:
The criteria is an aggregate phenomenon, such as in the case of uniqueness. It does not make sense to ask if any individual data element is unique, but the entire data vector must be unique. Happily, this condition is "downward compatible": If the criteria is an individual phenomenon (such as syntax), it can also tested in vectorised form against the entire vector.
The criteria may be in some transitive order.
For example, if a value is.integer()
it will also be is.numeric()
;
an integer is a special case of a numeric value.
Typically, these criteria may be listed in decreasing order of generality:
You'd first test if something is is.numeric()
and then whether it's also is.integer()
.
Formally, this means that predicate functions may be given in
negative transitive order,
where .lfn == FALSEimplies
.lfn+1 == FALSE`.
Abstracting away these ordered predicates with functional programming brings significant benefits:
It saves computation.
If .lf[n+1](.z)
is already known to be FALSE
,
it need not be run.
It helps improve expressiveness and reduces complexity of the predicates.
transitively
: Adverb to let predicate functions default to NA
for .x[!.prior]
.
Creates a function with two arguments:
.x
: An object to apply .p
to.
.prior
: A logical vector,
where FALSE
or NA
implies that .p(.x)
should not be run
but default to NA
.
...: Other arguments passed to .p()
.
Other helpers:
auth_cr()
,
auth_mailjet()
,
deployAppSaio()