Created
July 25, 2017 21:04
-
-
Save semuserable/82b45b3ba1c20853048bc19a0647709d to your computer and use it in GitHub Desktop.
This file contains 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
let data = [ | |
("January", 1); | |
("June", 10); | |
("March", 12); | |
("February", 20); | |
("January", 15); | |
("July", 15) | |
] | |
let grouped = | |
data | |
|> List.groupBy fst | |
|> List.map (fun (key, group) -> key, group |> List.sumBy snd) | |
|> List.map (fun (month, total) -> DateTime.ParseExact(month, "MMMM", CultureInfo.InvariantCulture), total) | |
|> List.sortBy (fun (month, _) -> month.Month) | |
|> List.map (fun (month, total) -> month.ToString("MMMM"), total) | |
|> Dump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment