David Shaked
David Shaked

Reputation: 3381

OCaml analogue to Python's String join method

Given a list of string elements in Python, I can concatenate these elements with specified glue. For example:

' '.join(["phd", "in", "everything"])

evaluates to the string "phd in everything".

What analogue in OCaml is considered most idiomatic? That is, how may string elements of a list be joined with some specified string in OCaml?

Upvotes: 2

Views: 209

Answers (1)

Pierre G.
Pierre G.

Reputation: 4431

The equivalent in Ocaml is :

#String.concat " " ["phd"; "in"; "everything"]

There is no restriction vs the length of the list.

Upvotes: 5

Related Questions