R/mod.R

Defines functions mod

Documented in mod

###
### $Id: mod.R 22 2022-05-30 18:03:47Z proebuck $
###
### Modulus after division.
###


##-----------------------------------------------------------------------------
mod <- function(x, y) {
    ans <- x %% y
    ## Substitute x[off] in answer anywhere y[off] equals zero
    if (length(zero.off <- which(y == 0))) {
        ans[zero.off] <- if (length(x) == 1) x else x[zero.off]
    }
    ans
}

Try the matlab package in your browser

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

matlab documentation built on July 1, 2024, 5:07 p.m.