我无法理解。如何找到最常用的名称,例如
type person = {name:string; surname:string}
let persons=[{name:"Jack";surname:"YYY"};
{name:"Joe";surname:"XYX"};
{name:"Jack";surname:"XXY"}]
我无法理解。如何找到最常用的名称,例如
type person = {name:string; surname:string}
let persons=[{name:"Jack";surname:"YYY"};
{name:"Joe";surname:"XYX"};
{name:"Jack";surname:"XXY"}]
// You have to use '=' instead of ':' between field names and field values
let persons =
[ {name = "Jack"; surname = "YYY"};
{name = "Joe"; surname = "XYX"};
{name = "Jack"; surname = "XXY"} ]
// val it : string = "Jack"
persons |> Seq.countBy (fun {name = s} -> s)
|> Seq.maxBy snd
|> fst