A friend of mine recently took a midterm in which the first problem asked him to create his own "baby.min()" function in R without utilizing "sort()" or "min()". This function was to operate in the same way as "min()". That is, min(x) returns the minimum value in some vector x.

I'm fairly new to programming and thus came up with a seemingly overly-complicated solution; however, I was wondering how succinct a function this really could be.

For reference, my idea for the function is as follows:

```
baby.min <- function(x){
  if (length(x) == 0) {
    return(Inf)
  } else {
    counter <- 0
    for (i in 1:length(x)){
      for (j in 1:length(x) & j != i){
        if (x[i] <= x[j]) {
          counter <- counter + 1
        } else {
          break
          counter <- 0
        }
      }
    if (counter == length(x) - 1){
      return(x[i])
    }
    }
  }
}

```

(Again, I understand this is probably a poor solution; I'm simply interested in seeing different ways in which better programmers than myself might solve it.)