Operators as functions
What is an operator, thinking abstractly? It can be seen as a function of one or two arguments that just have a concise name represented by a single symbol or a very few symbols. F# heartily supports this abstraction. For example, take a look at the following expression:
(%) 10 3 = 10 % 3
Here, on the left-hand side of the equality sign (=
), the (%)
function is called with the arguments 10
and 3
. On the right-hand side of the equality sign (=
) just a 10 % 3
expression is present. Evaluating the whole expression in FSI shows its value as true
because sub expressions on the left and right of the equality sign (=)
are indeed identical.
Furthermore, the equality sign (=
) itself is also an operator. Evaluating the equality sign ...
Get F# 4.0 Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.