let concat (l : string list) : string = fold_right (fun a x -> a ^ x) l ""
因此,通过它,我看到了
但是,如何func a x
知道a是列表的第一个元素,x是第二个元素。
当它再次通过时,如何知道a是列表的第三个元素,x是第四个元素,依此类推?
该accumulator
是第一个参数,a
到fold function
和x
是set to each element
名单依次为fold
走到了它。
的返回值fold function
是new value
的accumulator
。
的初始值accumulator
是empty string
,所以第一个串联,在成为的结果new accumulator
,是相同的值first element
的列表中的。
然后将next element
其连接到该字符串,依此类推,直到到达列表的末尾,这时将fold
返回final value of the accumulator
全连接字符串。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句