Anonymous user
Cartesian product of two or more lists: Difference between revisions
Cartesian product of two or more lists (view source)
Revision as of 21:22, 17 October 2019
, 4 years ago→{{header|OCaml}}
Line 1,871:
let cart_prod l1 l2 =
List.fold_left (fun acc1 ele1 ->
List.fold_left (fun acc2 ele2 -> (ele1,ele2)::acc2) acc1
cart_prod [1; 2; 3] ['a'; 'b'; 'c'] ;;
(*
cart_prod [1; 2; 3] [] ;;
(*- : ('a * int) list = [] *)
|