Logo

Programming-Idioms

History of Idiom 118 > diff from v52 to v53

Edit summary for version 53 by berov:
New Perl implementation by user [berov]

Version 52

2020-12-06, 22:36:35

Version 53

2020-12-12, 16:58:43

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);
Code
my @subset = uniq @values;
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