A quick and dirty solution would be to fasten the two lists and then smooth the resulting tuples:
let interleave a b =
List.zip a b |> List.collect (fun (a,b)-> [a;b])
Returns a list with alternating elements:
interleave a b;;
val it : string list = ["a"; "d"; "b"; "b"; "c"; "a"]
zip will create pairs from the elements of both lists:
val it : (string * string) list = [("a", "d"); ("b", "b"); ("c", "a")]
and collectwill smooth tuples
source
share