Table of Contents
Custom operators
If you create new operators, keep in mind that their precedence and associativity depend on the first character in the operator name (ignoring leading . and $).
That is:
- += has the same precedence as +
- *% has the same precedence as *
- .! has the same precedence as ! (this is infix)
Prefix operators start with !, ? and ~ (except those starting with += ).
Example
> let (+++) x y = x * x + y * y;; val ( +++ ) : int -> int -> int > 4 +++ 3;; val it : int = 25 > let (!+) x = abs x;; val ( !+ ) : int -> int > !+ -4;; val it : int = 4
See also
- Precedence and Operators (F# Draft Language Specification)