Created
July 20, 2015 17:23
-
-
Save richlander/d430d426788fbea9ff75 to your computer and use it in GitHub Desktop.
Constructors as first-class function values
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
// old approach | |
let makeStrings chars lens = | |
List.zip chars lens | |
|> List.map (fun (char, len) -> new System.String(char, len)) | |
// new approach | |
let makeStrings' chars lens = | |
List.zip chars lens | |
|> List.map System.String // use ctor as function | |
makeStrings' ['a';'b';'c'] [1;2;3] // ["a"; "bb"; "ccc"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment