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:09, 17 October 2019
, 4 years ago→{{header|OCaml}}
(Ocaml example using fold) |
|||
Line 1,871:
let cart_prod l1 l2 =
List.fold_left (fun acc1 ele1 ->
List.fold_left (fun acc2 ele2 -> (ele1,ele2)::acc2) acc1 l1) []
cart_prod [1; 2; 3] ['a'; 'b'; 'c'] ;;
|