Skip to content

Instantly share code, notes, and snippets.

@vasily-kirichenko
Last active December 12, 2015 02:28
Show Gist options
  • Save vasily-kirichenko/4698760 to your computer and use it in GitHub Desktop.
Save vasily-kirichenko/4698760 to your computer and use it in GitHub Desktop.
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