Last active
August 29, 2015 14:06
-
-
Save tobynet/972b3ab94937f6af2ac2 to your computer and use it in GitHub Desktop.
The playground about functional composition and pipeline operation in F#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playground | |
// ref. http://msdn.microsoft.com/ja-jp/library/dd233229.aspx | |
// | |
// All results are... 'val it : string = "abcdef"' | |
// | |
// Bacward pipeline operators only | |
['a'..'f'] |> List.map string |> List.reduce (+) | |
// With a composition operator | |
['a'..'f'] |> ( List.map string >> List.reduce (+) ) | |
// With a backward composition operator | |
['a'..'f'] |> ( List.reduce (+) << List.map string ) | |
// No more backward pipline operators | |
( List.map string >> List.reduce (+) ) ['a'..'f'] | |
( List.reduce (+) << List.map string ) ['a'..'f'] | |
// Normal pipeline operators | |
List.reduce (+) <| List.map string ['a'..'f'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment