Q:

returning boolean value in function

I have this function:
let myFunction list (var1, var2) : bool =
    for (x,y) in list do
        match (var1, var2) with
        | (1, 11) | (2, 22) -> true
        | (_, _) ->
            if not (x = y) then
                true // error is here
            false

This returns an error saying that the function expects the value returned to have type bool, not unit. What I want to achieve is to return true whenever x != y so the loop should stop there; otherwise to return false at the end.

A:

In F#, if statements can return.  As a result, if you put the true on its own, you need to put a matching false so that both sides of the if return bool like so
        if not (x = y) then
            true 
        else false

