[JOB] Perl Software Developer and Database programmer

Ovid publiustemp-londonpm at yahoo.com
Wed Feb 22 17:42:59 GMT 2006


--- Dirk Koopman <djk at tobit.co.uk> wrote:

> >   1.  What is a likely reason for the performance problem?
> >   2.  How might we speed it up?

> How about:
> 
> my @beta = (1,3,5,6,7,9);
> my @alpha = (2,3,4,8,9,10);
> 
> my %beta;
> 
> @beta{@beta} = ();
> my @results = grep {exists $beta{$_}} @alpha;
> 
> print join(',', @results), "\n";

What's wrong with ...

    use Quantum::Superpositions;

    my @alphas = qw/ 9 4 3 2 22  13 7  140 95 278/;
    my @betas  = qw/ 8 3 4 1 278 94 15 7   19 200/;
    my @results = eigenstates( any(@alphas) == any(@betas) );

Seriously, though, most competent Perl programmers will come up with
hash-based solution.  Interestingly, many competent programmers who
don't know Perl come up with something which doesn't involve hashes or
grep since those are not built-ins in many mainstream languages.

There's a moderately interesting discussion of this at
http://www.perlmonks.org/?node_id=162711.  That's where I stole the
Quantum::Magic code.

Cheers,
Ovid

-- 
If this message is a response to a question on a mailing list, please send follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/


More information about the london.pm mailing list