apropos <- function (pattern, where = FALSE)
{
  if (!is.character(pattern))
    stop("`pattern' must be a character string")
  x <- character(0)
  for (i in seq(search())) {
    ll <- length(li <- ls(pos = i, pattern = pattern, all.names = TRUE))
    if (ll) x <- c(x, if (where) structure(li, names = rep(i, ll)) else li)
  }
  x
}
