Last active
December 12, 2015 02:28
-
-
Save vasily-kirichenko/4698760 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
type Person = { Name: string; Flag: bool } | |
let sortedKeyList = | |
List.concat | |
>> List.map (fun { Name = name } -> name) | |
>> Seq.distinct | |
>> Seq.sort | |
>> String.concat ", " | |
>> (function "" -> "<none>" | s -> s) | |
[<Fact>] | |
let ``Sorted key list``() = | |
let persons = List.map (fun name -> { Name = name; Flag = true }) | |
[ | |
[], [], "<none>" | |
["fred"], ["barney"; "wilma"], "barney, fred, wilma" | |
["fred"], [], "fred" | |
["fred"], ["fred"; "barney"], "barney, fred" | |
] | |
|> List.iter (fun (a, b, res) -> sortedKeyList [a |> persons; b |> persons] =? res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment