in reply to Combinations of multiple arrays
Simple map-in-map algorithm.
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=817521 use warnings; my @list = ([0..1], [2..4], [5..8]); my @sets = []; for my $eacharray ( @list ) { @sets = map { my @prev = @$_; map [ @prev, $_ ], @$eacharray } @sets +; } use Data::Dump 'dd'; dd @sets;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Combinations of multiple arrays
by thomas895 (Deacon) on Sep 09, 2020 at 03:42 UTC |