Skip to content

Instantly share code, notes, and snippets.

@richlander
Created July 20, 2015 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richlander/d430d426788fbea9ff75 to your computer and use it in GitHub Desktop.
Save richlander/d430d426788fbea9ff75 to your computer and use it in GitHub Desktop.
Constructors as first-class function values
// 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