Logo

Programming-Idioms

History of Idiom 118 > diff from v53 to v54

Edit summary for version 54 by programming-idioms.org:
[Perl] Variable names x, y

Version 53

2020-12-12, 16:58:43

Version 54

2020-12-28, 22:44:27

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Variables
y,x
Variables
y,x
Imports
use List::Util qw(uniq);
Imports
use List::Util qw(uniq);
Code
my @subset = uniq @values;
Code
my @y = uniq @x;
Comments bubble
Filters a list of values to remove subsequent duplicates. Preserves the order of unique elements, and retains the first value of any duplicate set.
Comments bubble
Filters a list of values to remove subsequent duplicates. Preserves the order of unique elements, and retains the first value of any duplicate set.
Doc URL
https://perldoc.perl.org/List::Util#uniq
Doc URL
https://perldoc.perl.org/List::Util#uniq