Logo

Programming-Idioms

History of Idiom 118 > diff from v12 to v13

Edit summary for version 13 by Roboticus:
New Perl implementation by user [Roboticus]

Version 12

2016-04-06, 20:25:51

Version 13

2016-04-21, 10:51:30

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.

Code
my %y = map {$_=>0} @x;
Comments bubble
Convert a list to a hash, the value is unimportant, so we used 0.