in reply to Re: Efficient Unique Nested Combinations
in thread Efficient Unique Nested Combinations

I resorted to using a hash to catch what had been seen. The model still offers some short-circuiting, and is moderately faster than "hash" in my benchmarking (the more duplicates there are to avoid, the better "combo" does). Note also that you didn't change my code to use the passed-in array ref. I have done so here.
sub combo { my $symbols = shift; my %seen; my $combos = NestedLoops([ $symbols->[0], map { my $_hold = $_; sub { [grep {!$seen{join(':', sort @_, $_)}++} @{$symbols->[$_hold +]}] } } 1..$#$symbols ]); while (my @result = $combos->()) { print "@result\n"; } print "\n"; }

Caution: Contents may have been coded under pressure.