Splitting a list of items into two lists of odd and even indexed items

Implementation which does not stack-overflows:

let splitList list = List.foldBack (fun x (l,r) -> x::r, l) list ([],[])

Leave a Comment