Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Combinations with variable length

by tybalt89 (Prior)
on May 10, 2021 at 21:30 UTC ( #11132354=note: print w/replies, xml ) Need Help??


in reply to Combinations with variable length

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11132353 use warnings; my @static = qw( 1 2 ); my $nonstatic = 3; my @item = []; @item = map { my $static = $_; map [ $static, @$_ ], @item } @static for 1 .. $nonstatic; use Data::Dump 'dd'; dd \@item;

Outputs:

[ [1, 1, 1], [1, 1, 2], [1, 2, 1], [1, 2, 2], [2, 1, 1], [2, 1, 2], [2, 2, 1], [2, 2, 2], ]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2021-08-02 17:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (28 votes). Check out past polls.

    Notices?