Skip to content

Instantly share code, notes, and snippets.

@vasily-kirichenko
Last active December 12, 2015 02:18
Show Gist options
  • Save vasily-kirichenko/4697027 to your computer and use it in GitHub Desktop.
Save vasily-kirichenko/4697027 to your computer and use it in GitHub Desktop.
let sortedKeyList =
Seq.map (Map.toSeq >> Seq.map fst)
>> Seq.concat
>> Seq.distinct
>> Seq.sort
>> String.concat ", "
>> (function "" -> "<none>" | s -> s)
[<Fact>]
let ``Sorted key list``() =
[[], [], "<none>"
["fred", true], ["barney", true; "wilma", true], "barney, fred, wilma"
["fred", true], [], "fred"
["fred", true], ["fred", true; "barney", true], "barney, fred"]
|> List.iter (fun (m1, m2, res) -> sortedKeyList [Map.ofSeq m1; Map.ofSeq m2] =? res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment