http://www.perlmonks.org?node_id=585575


in reply to Ultra compact set searching

I can't see your and_maker, but based on its interface, I'm guessing you're actually building a sub. I suppose that works, but instead, what about:

sub multi_and { my $result = shift; while (@_) { $result &= shift; } $result; }

That might be used like:

my $results1 = multi_and(1,2,3); # 3 args my $results2 = multi_and(5,6,7); # 3 args my $results3 = multi_and(12,13,14,15,16); # 5 args

No code generation, should be pretty fast. If the repeated shift is a problem, then this should work, too:

sub multi_and { my $result = shift; for (@_) { $result &= $_ } $result }
<radiant.matrix>
Ramblings and references
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet