Skip to content

Instantly share code, notes, and snippets.

@cwfoo
Created April 23, 2021 16:09
Show Gist options
  • Save cwfoo/df0277fe1fcc832d1d78e2102d636e92 to your computer and use it in GitHub Desktop.
Save cwfoo/df0277fe1fcc832d1d78e2102d636e92 to your computer and use it in GitHub Desktop.
OCaml implementation of Haskell's Data.List intersperse and intercalate.
(* OCaml implementation of Haskell's Data.List intersperse and intercalate. *)
let rec intersperse sep ls =
match ls with
| [] | [_] -> ls
| x::xs -> x :: sep :: intersperse sep xs
let intercalate = String.concat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment