On Aug 2, Charles Lu said:

>@list = (1,2,3,4,2,67,4,4,9);
>
>I want to remove all the redundant ones so the final list should
>contain (1,2,3,4,67,9).   Although I have implemented my own way of doing 
>it, I think this problem is quite common and therefore someone must have 
>written a function for it.  Can anyone suggest a module/builtin function  
>that takes a number and checks to see it that number already exists in an 
>array?  basically a "is_in()" function that returns true or false.

The key is not to use a hash to do the checking.

This has been asked many times, and is in the FAQ:

http://www.perlfaq.com/cgi-bin/view?view_by_id=93
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_can_I_extract_just_the_uniqu

Or you can get it via the perldoc command:

  perldoc -q unique

or

  perldoc -q duplicate

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


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

Reply via email to