I\'ve found this question on hubFS, but that handles a splitting criteria based on individual elements. I\'d like to split based on a comparison of adjacent elements, so the
let splitOn test lst =
List.foldBack (fun el lst ->
match lst with
| [] -> [[el]]
| (x::xs)::ys when not (test el x) -> (el::(x::xs))::ys
| _ -> [el]::lst
) lst []
the foldBack removes the need to reverse the list.