[back]

Splitting Lists

Implement the function

val split : ('a * 'b) list -> 'a list * 'b list

so that split_list l is a pair of lists (lefts, rights) where lefts consists of the first elements of every pair in l (in order) and rights consists of the second elements of every pair in l (in order).

Examples

let _ = assert (split_list [] = ([], []))
let _ = assert (split_list [(1, "a"); (2, "b"); (3, "c")] = ([1;2;3], ["a";"b";"c"]))