R/first_which.R

Defines functions last_which first_which

first_which <- function(expr) {
  o <- which(expr)
  if (length(o)) {
    return(o[1])
  } else {
    return(0L)
  }
}

last_which <- function(expr) {
  o <- which(expr)
  if (length(o)) {
    return(last(o))
  } else {
    return(0L)
  }
}
HughParsonage/hutilscpp documentation built on March 1, 2025, 12:29 p.m.