如何定义将字母数组分解为一组字符串的函数

How to define a function to break an array of letters into a group of string

我有这样的 C# 代码

// Class definition
Class Letter {
    char c;
    int id;
}

// A C# function to obtain an array of letters
Array[Letter] getLetters();

来自 F# 的函数调用

let L = getLetters()

我想将 L 分成按 id 分组的字符串列表,假设 id0N。我怎样才能在 F# 中做到这一点?我是 F# 新手。

let rslt letters = 
    letters 
    |> Seq.groupBy (fun l -> l.id) // Groups Letters into sequence of pair (id * seq<Letter>) 
    |> Seq.map (fun (_, str) -> str |> Seq.map (fun l -> l.c) ) // Maps the sequence to seq<seq<<char>> 
    |> Seq.map (fun ls -> System.String.Join("", ls)) // Maps the sequence to seq<string>
    |> List.ofSeq // Creates list of strings from seq<string>