我有字符串数组的数组。我需要将它们弄平,然后使用:
Array.fold (fun acc el -> Array.append acc el) [||] arr2d
Lint对我说:
"If Array.append has not mutable arguments partially applied then the lambda can be removed"
这是什么意思?如何删除lambda?
最佳答案
任何形式为(fun x -> f x)
的lambda函数都可以表示为f
。保持不变的条件。
在您的代码中,您拥有fun acc el -> Array.append acc el
,它具有与Array.append
相同的类型并且具有相同的类型,因此您可以将其缩短为:
Array.fold Array.append [||] arr2d
关于arrays - 如果Array.append没有部分应用可变参数,则可以删除lambda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33898648/