Tutorial by Examples

In F#, all functions take exactly one parameter. This seems an odd statement, since it's trivially easy to declare more than one parameter in a function declaration: let add x y = x + y But if you type that function declaration into the F# interactive interpreter, you'll see that its type signat...
Most functions in F# are created with the let syntax: let timesTwo x = x * 2 This defines a function named timesTwo that takes a single parameter x. If you run an interactive F# session (fsharpi on OS X and Linux, fsi.exe on Windows) and paste that function in (and add the ;; that tells fsharpi ...
There are two ways to define functions with multiple parameters in F#, Curried functions and Tupled functions. let curriedAdd x y = x + y // Signature: x:int -> y:int -> int let tupledAdd (x, y) = x + y // Signature: x:int * y:int -> int All functions defined from outside F# (such as ...
Inlining allows you to replace a call to a function with the body of the function. This is sometimes useful for performance reason on critical part of the code. But the counterpart is that your assembly will takes much space since the body of the function is duplicated everywhere a call occurred. Y...
Pipe operators are used to pass parameters to a function in a simple and elegant way. It allows to eliminate intermediate values and make function calls easier to read. In F#, there are two pipe operators: Forward (|>): Passing parameters from left to right let print message = print...

Page 1 of 1