[back]

Splits

A split of a list l is a pair of lists l1 and l2 such l1 @ l2 = l.

Implement the function

val splits : 'a list -> ('a list * 'a list) list

so that splits l is the list of all possible splits of l, in order of increase length of the left list in the split.

Examples

let _ = assert (splits [] = [([], [])])
let _ = assert (splits [1;2;3] =
    [([], [1;2;3]); ([1], [2;3]); ([1;2], [3]); ([1;2;3], [])])