Hi

        sub harryGrep {
        return [ grep { not $\{$_}++ } @_ ];
        }


It took me quite a while to find something quicker than the original grep
using the function I first tried and then I happened across a piece of text
talking about return contexts and tried the above. I also noticed a little
bit of code from Drieux's page's  and tried this and knocked nearly 0.5s off
it again

sub unique{foreach (@_) { $_{$_}++} [keys %_]}

sub GrepMe { [ grep { ! $/{$_}++} @_ ]} 

I did not know you could drop the return until I seen Drieux do it. Another
method that is quicker than my foreach attempt is the following.

sub unique{ map { $_{$_} = 1 } @_;  [keys %_] }

I would like to have been able to do something like the following but it
does not work?


sub unique{ [ keys {map { $_{$_} = 1 } @_ }]  }

I think the BLOCK {map { $_{$_} = 1 } @_ } returns a reference and it will
need to be de-referenced for keys to work but I cannot figure it out any
ideas anyone.

H





*************************************************************************************
COLT Telecommunications
Registered in England No. 2452736
Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ
Tel. +44 20 7390 3900

This message is subject to and does not create or vary any contractual
relationship between COLT Telecommunications, its subsidiaries or 
affiliates ("COLT") and you. Internet communications are not secure
and therefore COLT does not accept legal responsibility for the
contents of this message.  Any view or opinions expressed are those of
the author. The message is intended for the addressee only and its
contents and any attached files are strictly confidential. If you have
received it in error, please telephone the number above. Thank you.
*************************************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to