如何在 F# 中将 SequenceEqual 与 StringComparer.OrdinalIgnoreCase 一起使用?
How to use SequenceEqual with StringComparer.OrdinalIgnoreCase in F#?
在 C# 中,我有以下代码片段:
string[] words = { "how", "are", "you" };
string[] words2 = { "HOW", "are", "YOU" };
var result = words.SequenceEqual(words2, StringComparer.OrdinalIgnoreCase);
并且 result
的值为真。
在 F# 中我想做同样的事情:
let words = [|"how", "are", "you"|]
let words2 = [|"HOW", "are", "YOU"|]
let result = words.SequenceEqual(words2, StringComparer.OrdinalIgnoreCase)
但是编译器抱怨:
The type StringComparer
is not compatible with the type Collections.Generic.IEqualityComparer<string * string * string>
如何将 StringComparer.OrdinalIgnore
用于我在 F# 中的示例?
需要用;
分隔数组元素:
let words = [|"how"; "are"; "you"|]
let words2 = [|"HOW"; "are"; "YOU"|]
,
用于分隔元组中的元素,因此您当前有两个包含 string * string * string
.
类型的 3 元素元组的 1 元素数组
在 C# 中,我有以下代码片段:
string[] words = { "how", "are", "you" };
string[] words2 = { "HOW", "are", "YOU" };
var result = words.SequenceEqual(words2, StringComparer.OrdinalIgnoreCase);
并且 result
的值为真。
在 F# 中我想做同样的事情:
let words = [|"how", "are", "you"|]
let words2 = [|"HOW", "are", "YOU"|]
let result = words.SequenceEqual(words2, StringComparer.OrdinalIgnoreCase)
但是编译器抱怨:
The type
StringComparer
is not compatible with the typeCollections.Generic.IEqualityComparer<string * string * string>
如何将 StringComparer.OrdinalIgnore
用于我在 F# 中的示例?
需要用;
分隔数组元素:
let words = [|"how"; "are"; "you"|]
let words2 = [|"HOW"; "are"; "YOU"|]
,
用于分隔元组中的元素,因此您当前有两个包含 string * string * string
.