Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Parallelization of multiple nested loops

by QM (Parson)
on Feb 07, 2018 at 11:53 UTC ( #1208624=note: print w/replies, xml ) Need Help??

in reply to Parallelization of multiple nested loops

You could also rework the nested loops into permutations or globs, and just have a single loop with an iterator.

I would naively suggest glob, but for your example, it eats up memory, and probably doesn't finish:

#!/usr/bin/env perl use strict; use warnings; # dummy values for @p, to get the last values not in a loop my @p = 0..12; # a single value # (this can be generalized, as parameters to a function to generate th +is string) my $glob_token = '{0.0,0.2,0.4,0.6,0.8,1.0}'; # join into multiple value string # (must use non-whitespace, as the builtin glob treats whitespace spec +ial) my $glob_parm = join(",", ($glob_token) x 11); # Loop fork for my $parm_list (glob($glob_parm)) { # now fix the commas $parm_list =~ s/,/\t/g; my $temp_out = "$parm_list\t$p[11]\t$p[12]\n"; print $temp_out; }

A similar solution using permutations a combination iterator would work. I'll have to see if I can find my array-of-arrays permutation iterator.

Update: This node on this thread should help.

Quantum Mechanics: The dreams stuff is made of

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2021-03-02 21:40 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (63 votes). Check out past polls.