Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stefanalfbo/2218950 to your computer and use it in GitHub Desktop.
Save stefanalfbo/2218950 to your computer and use it in GitHub Desktop.
Simple examples of pipeline operator in F#
// Some functions to play with
let double x = x * 2
let triple x = x * 3
let square x = x * x
// fsi
>2 |> double;;
val it : int 4
let pipelining n =
n
|> double
|> triple
|> square
// fsi
> pipelining 10;;
val it : int = 3600
// when a function takes more than one parameter
let subtract x y = y - x
// fsi
> subtract 2 4;;
val it : int = 2
// here the 2 will bind to x and y to 4
> 4 |> subtract 2;;
val it : int = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment