strict (version 0.0.0.9000)

strict_sample: Strict behaviour for functions with special scalar behaviour

Description

[sample()] and [diag()] behave differently depending on whether their first argument is a scalar or a function. These shims throw an error when given a scalar to force you to pick a safer alternative.

Usage

strict_sample(x, size = length(x), replace = FALSE, prob = NULL)

strict_diag(x = 1, nrow, ncol)

Arguments

x, size, replace, prob, nrow, ncol

Passed on to [sample()] and [diag()]

Examples

Run this code
# NOT RUN {
lax({
  sample(5:3)
  sample(5:4)
  sample(5:5)

  diag(5:3)
  diag(5:4)
  diag(5:5)
})

# }
# NOT RUN {
  sample(5:5)
  diag(5)
# }

Run the code above in your browser using DataLab