[back]

Every Other

Implement the function

val every_other : int list -> int list * int list

so that every_other l is a pair of lists such that the first list contains every other element of l starting at the 0-th element, and the second list contains every other element of l starting at the 1-th element. You must maintain the relative order of elements.

Examples

let _ = assert (every_other [1;3;5;2;4;6] = ([1;5;4], [3;2;6]))
let _ = assert (every_other [1] = ([1], []))
let _ = assert (every_other [] = ([], []))