Aaron Cohen > Set-Functional-1.0 > benchmarks/disjoint.pl

Download:
Set-Functional-1.0.tar.gz

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Source  
        'exists_fn' => sub {
                my $lhs = get_next();

                my %set;
                @set{ map { $id->($_) } @$lhs } = @$lhs;

                for (get_rand(), get_rand(), get_rand(), get_rand()) {
                        my @int = grep { exists $set{$id->($_)} } @$_;
                        return unless @int;
                        undef %set;
                        @set{ map { $id->($_) } @int } = @int;
                }
                return keys %set;
        },

        'slice_defined_fn' => sub {
                my $lhs = get_next();

                my %set;
                @set{ map { $id->($_) } @$lhs } = @$lhs;

                for (get_rand(), get_rand(), get_rand(), get_rand()) {
                        my @int = grep { defined } @set{ map { $id->($_) } @$_ };
                        return unless @int;
                        undef %set;
                        @set{ map { $id->($_) } @int } = @int;
                }
                return keys %set;
        },

});

syntax highlighting: