The question spread() asks of spreadProb before it starts. Expressed in R as all(inRange(na.omit(x))) it costs three passes and two copies of the whole vector – na.omit() allocates one, the comparison another – which is work proportional to the size of the landscape on every call, however little of it burns. This is one pass, no allocation, and it stops at the first value that fails.

NA and NaN are ignored, so an all-NA vector and a zero-length vector are both TRUE: there is nothing in them that is out of range. That matches all(inRange(na.omit(x))), which is all(logical(0)).

allInRange01(x)

Arguments

x

Numeric vector.

Value

A single logical.