Is there a way to do a multiple value comparison inline?

comparison, f#

Solution

To check if every value in a list is the same:

let rec same = function
  | x::y::_ when x <> y -> false
  | _::xs -> same xs
  | [] -> true

Usage

let a, b, c = 1, 1, 1
same [a; b; c] //true

Problem

I feel silly for even asking this because it seems so trivial but my brain is failing me. If I had the following: ``` let a, b, c = 1, 1, 1 ``` Is there an eligant way to determine if a, b, and c all hold the same value. Something like: ``` let result = (a = b = c) ``` This fails because the expression `a = b` returns true and the next expression results in `true = c` and complains that it was expecting int, not bool. The only thing I can think of is: ``` a = b && a = c && b = c ``` which won't work when I want to add more variables. Really what I'm trying to do is this: ``` let same (x: string * string * string) = match x with | (a, a, a) -> true | _ -> false ``` I was hoping that I could match all the elements into one element and if they were different it would move on, but it says on the second element in the match that it has already been bound.

Original source