github-tui/lib/list_extra.ml
2024-01-29 19:05:08 +00:00

8 lines
176 B
OCaml

let in_between ~sep list =
let rec loop = function
| [] -> []
| x :: xs -> sep :: x :: loop xs
in
match list with
| [] | [_] -> list
| x :: xs -> x :: loop xs