I would like to make a function that accepts a list and returns two lists: the first contains every odd item, and the second contains every even item.
For example, g
It looks like this is what you were going for, which is indeed a nice way to do it as it's tail-recursive.
let splitList items =
let rec splitOdd odds evens = function
| [] -> odds, evens
| h::t -> splitEven (h::odds) evens t
and splitEven odds evens = function
| [] -> odds, evens
| h::t -> splitOdd odds (h::evens) t
let odds, evens = splitOdd [] [] items
List.rev odds, List.rev evens