async_every: Do every or some elements of a list satisfy an asynchronous...

View source: R/every.R

async_everyR Documentation

Do every or some elements of a list satisfy an asynchronous predicate?

Description

Do every or some elements of a list satisfy an asynchronous predicate?

Usage

async_every(.x, .p, ...)

async_some(.x, .p, ...)

Arguments

.x

A list or atomic vector.

.p

An asynchronous predicate function.

...

Additional arguments to the predicate function.

Value

A deferred value for the result.

See Also

Other async iterators: async_detect(), async_filter(), async_map()

Examples

# Check if all numbers are odd
# Note the use of force() here. Otherwise x will be evaluated later,
# and by then its value might change.
is_odd <- async(function(x) {
  force(x)
  delay(1/1000)$then(function() as.logical(x %% 2))
})
synchronise(async_every(c(1,3,5,7,10,11), is_odd))
synchronise(async_every(c(1,3,5,7,11), is_odd))

gaborcsardi/async documentation built on Nov. 20, 2024, 4:51 p.m.