in reply to How to get this not the usual round robin looping
My humble solution:
use strict; use warnings; use Data::Dumper; my @K = qw (H1 H2 H3 H4); my @V = qw (1 2 3 4 5 6 7 8 9 10); my %hash; my $i = -1; push @{ $hash{ $K[ ++$i&4 ? 3-$i%4 : $i%4 ] } }, $_ for @V; print Dumper \%hash;
UPDATE: ...or...
push @{ $hash{ $K[ int 3.5*abs sin (0.19634954085+0.39269908170*++$i) +] } }, $_ for @V;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to get this not the usual round robin looping
by Discipulus (Canon) on Oct 14, 2015 at 07:48 UTC | |
by hdb (Monsignor) on Oct 14, 2015 at 08:47 UTC | |
Re^2: How to get this not the usual round robin looping
by karlgoethebier (Abbot) on Oct 13, 2015 at 17:05 UTC | |
by hdb (Monsignor) on Oct 13, 2015 at 19:18 UTC |