I'm quite sure that I don't understand your reference to "randomly select a string with four elements from a data frame with 1553 strings..." -- so, as in Kenosis reply above, I've worked with a string comprised of "A" .. "Z" and taken a couple additional steps to obtain the one-thousandth permutation *1 (shuffle) thereof:
#!/usr/bin/perl use 5.016; use warnings; use List::Util qw/shuffle/; my $runs = 10^3; my $range = 1553; my @letterRange = ( 'A' .. 'Z' ); my $i = 0; my (@array, @arr2, $key, $valref, $permutes); my %permutes = (); for ($i=1;$i<=$range;$i++) { # C-style, start w/"1"; "0" would g +ive 1554 elements @array = shuffle @letterRange for 1 ..$runs; # @arr will hold th +e 1000th shuffle $key = "@array"; $permutes {$key } = $i; } for my $key ( keys %permutes ) { my $value = $permutes{$key}; push @arr2, "$value => $key"; } print "size of hash: " . keys( %permutes ) . ".\n"; no warnings 'numeric'; my @sorted = sort {$a <=> $b} @arr2; use warnings; for $_ (@sorted) { say $_; }
The output looks like this:
size of hash: 1553. 1 => V Y N H D R W Q C B E F T L S I J M O U Z A G X P K 2 => W E C B M V P I Y U D K G A T Z R O N F S J L X Q H 3 => L A T Y N R C Z J O V U G Q H F B S K W I E X P M D ...
... no dupes, no missing iteration numbers found but a selection of the output is in the readmore which follows:
4 => G O R J Z B I V Q D H W E N U L T F K X A M C P S Y 5 => M W E F R T K H N Y D Q P S A C O Z B V U J I G X L 6 => D Q B M C P A O I U H J W G S Z T L Y V N K R F E X 7 => I C F P M U K T W E D Z V H A X S Q O J G B Y N R L 8 => B P Y R Q C U T X L Z J F K I D V H M O W A E N G S 9 => C D V X A P T F S Y E W H G K U Q N B Z I O M R L J ... (Including all the output led to truncation of this node) 1550 => G M V L S P H F A J D Y I E X W K R B T O Z U Q N C 1551 => Y A J X K Q S O F U Z C W E H V B G I R N M L T D P 1552 => F W H T R S K E M U X D O I B N A J L Z G V P Y C Q 1553 => X V E F J N W A Z C G H R K O Q U P L I Y M B D T S
*1: Reiterating, I doubt this is the solution to your problem -- as noted above, I simply don't understand a part of your problem statement (and the code doesn't illuminate the meaning for /me) but I do hope this may offer an approach to your specific case.
In reply to Re: A Question with Nesting Arrays
by ww
in thread A Question with Nesting Arrays
by ccelt09
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |