Thursday, November 1, 2018

Being Lazy

Just discovered Array::Utils!  Wonderful!  To think I was going to write a "find unique elements in an array" myself.  Nope!

use Array::Utils qw(:all);
my @unique = unique(@a, @b);
 
 
 

2 comments:

  1. FYI there are `uniq`, `uniqstr` and `uniqnum` functions from List::Util which does this silghtly differently then `unique` from Array::Utils.

    If the problem you're dealing with requires you to maintain the order of elements in `unique @a` to be the same as their first occurance in `@a`, then the functions from List::Util can help you.

    ReplyDelete