Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Combinations of multiple arrays

by tybalt89 (Prior)
on Sep 08, 2020 at 22:48 UTC ( #11121500=note: print w/replies, xml ) Need Help??


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

    Inspiration struck after 10 years? ;-)

    -Thomas
    "Excuse me for butting in, but I'm interrupt-driven..."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11121500]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2020-10-27 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (256 votes). Check out past polls.

    Notices?