[back]

Prefixes

A prefix of a list l is a list pre such that there is a list suf where pre @ suf = l.

Implement the function

val prefixes : 'a list -> 'a list list

so that prefixes l is the list of all prefixes of l in increasing order of length.

Examples

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