R/utils-asserts.R

Defines functions is_sorted.numeric is_sorted

is_sorted <- function(x, ...) {
    UseMethod("is_sorted", x)
}

assertthat::on_failure(is_sorted) <- function(call, env) {
    paste0(deparse(call$x), " is not sorted.")
}

#' @export
is_sorted.numeric <- function(x, ...) {
    all(diff(x) >= 0)
}

Try the einops package in your browser

Any scripts or data that you put into this service are public.

einops documentation built on Sept. 9, 2025, 5:29 p.m.