OCaml 类似于 Python 的 String join 方法

Dav*_*ked 2 ocaml

给定 Python 中的字符串元素列表,我可以使用指定的胶水连接这些元素。例如:

' '.join(["phd", "in", "everything"])
Run Code Online (Sandbox Code Playgroud)

计算结果为字符串"phd in everything"

OCaml 中的哪个类似物被认为是最惯用的?也就是说,列表的字符串元素如何与OCaml 中的某个指定字符串连接?

Pie*_* G. 5

Ocaml 中的等价物是:

#String.concat " " ["phd"; "in"; "everything"]
Run Code Online (Sandbox Code Playgroud)

列表的长度没有限制。