Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 531

Standard name for operation of type ('a list -> ('a ->'b list) ->'b list list) which distributes each element?

$
0
0

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!


Viewing all articles
Browse latest Browse all 531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>