Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

commafy

Lib.commafy : string list -> string list

Add commas into a list of strings.

An application commafy [s1,...,sn] yields [s1, ",", ..., ",", sn].

Failure

Never fails.

Example

> commafy ["donkey", "mule", "horse", "camel", "llama"];
val it =
   ["donkey", ", ", "mule", ", ", "horse", ", ", "camel", ", ", "llama"]:
   string list

> String.concat it;
val it = "donkey, mule, horse, camel, llama": string

> commafy ["foo"];
val it = ["foo"]: string list