I've chosen not to give this a by argument because it doesn't matter for the 99% case, but if we ever did want to go back and add that in we'd need to check that the result of the seq() call was a regular sequence that fully included to. We'd also need to check that by isn't negative. This helper could help with the first part:
check_regular_seq <- function(out, from, to, by, ..., call = caller_env()) {
check_dots_empty0(...)
size <- vec_size(out)
# If `out` is empty, `x` was empty.
# Otherwise, `by` is required to break `x` into a regular sequence,
# meaning `to` must be included as the last value of the sequence.
if (size == 0L || vec_equal(to, out[[size]])) {
return(invisible(NULL))
}
message <- c(
"{.arg by} must create a regular sequence along the limits of {.arg x}.",
i = "{.arg by} is {by}.",
i = "{.arg x} has a lower limit of {from}.",
i = "{.arg x} has an upper limit of {to}."
)
cli::cli_abort(message, call = call)
}
Closes #279
I've chosen not to give this a
by
argument because it doesn't matter for the 99% case, but if we ever did want to go back and add that in we'd need to check that the result of theseq()
call was a regular sequence that fully includedto
. We'd also need to check thatby
isn't negative. This helper could help with the first part: