[back]

Suffixes

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

Implement the function

val suffixes : 'a list -> 'a list list

so that suffixes l is the list of all suffixes of l in decreasing order of length.

Examples

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