Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Combinations of multiple arrays

by tybalt89 (Monsignor)
on Sep 08, 2020 at 22:48 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121500]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-25 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found