[back]

Drop Trailing

Implement the function

val drop_trailing : 'a -> 'a list -> 'a list

so that drop_trailing k l is the result of removing all instances of k from the end of the list l.

Examples

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