[thelist] Generating possible combinations without nested loops
Martin Burns
martin at easyweb.co.uk
Tue Aug 27 12:52:23 CDT 2013
Just a left field thought:
Aren't you essentially trying to populate an array with every binary number from 0 to 2^n? So wouldn't a single loop & dec->binary conversion do it? Or even a 0 to (2^n)/2 with a binary NOT after the conversion?
Cheers
Martin
On 24 Aug 2013, at 03:29, erik mattheis <gozz at gozz.com> wrote:
> I've a function test() that takes many (6+) parameters each of which is a
> Boolean value. I can call the function in,
>
> for (a in 0...2) {
> for (b in 0...2) {
> for (c in 0...2) {
> test(a,b,c);
> }
> }
> }
>
> but I'm wondering if there's a more efficient (or eloquent) way of
> generating the required permutations of a,b and c. Ideas?
> --
> Erik Mattheis
>
> http://www.flickr.com/gelk
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
More information about the thelist
mailing list