As mentioned, the |> tube operator helps with function compilation and type inferences. This allows you to change function parameters so that you can first place the last function parameter. This allows a chain of functions that are very readable (similar to LINQ in C #). Your example does not show the power of this - it really shines when you have a pipeline transformation configured for several functions in a line.
Using the |> chain, you can write:
let createPerson n = if n = 1 then "Homer" else "Someone else" let hello name = "Hello " + name + "!" let solution2 = 1 |> createPerson |> hello |> printf "%s"
Feedback Operator Advantage <| is that it changes the priority of the operator, so it can save a lot of brackets: function arguments are usually evaluated from left to right using <| you don't need parentheses if you want to pass the result of one function to another function - your example really doesn't use this.
They would be equivalent:
let createPerson n = if n = 1 then "Homer" else "Someone else" let hello name = "Hello " + name + "!" let solution3 = hello <| createPerson 1 let solution4 = hello (createPerson 1)
source share