which <- function(x) {
	if(is.logical(x)) seq(x)[x]
	else stop("argument to \"which\" is not logical")
}
