Now I have some Scala code similar to the following:

```
def foo(x: Int, fn: (Int, Int) => Boolean): Boolean = {
  for {
    i <- 0 until x
    j <- i + 1 until x
    if fn(i, j)
  } return true
  false
}

```

But I get the feeling that `return true` is not so functional (or maybe it is?). Is there a way to rewrite this piece of code in a more elegant way?

In general, what is the more functional (if any) way to write the return-early-from-a-loop kind of code?