Is there a "standard" name or a generalized pattern for the following operation (written in OCaml with monadic let binding):
let rec combine (xs : 'a list) (f : 'a -> 'b list) : 'b list list = let open List.Let_syntax in match xs with | [] -> return [] | x :: xs -> let%bind y = f x in let%bind ys = combine xs f in return (y :: ys)
It applies f
to each element of xs
and collects every possible combinations of the computation.
Thanks in advance!