Logo

Programming-Idioms

History of Idiom 118 > diff from v10 to v11

Edit summary for version 11 by :
New JS implementation by user [Patman64]

Version 10

2016-02-16, 20:15:45

Version 11

2016-02-18, 16:58:03

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
bool[typeof(x[0])] y;

foreach (e ; x)
    y[e] = true;
Code
bool[typeof(x[0])] y;

foreach (e ; x)
    y[e] = true;
Comments bubble
D doesn't have a set type, use an associative array.
You may replace typeof(x[0]) with the named type of the elements.
Comments bubble
D doesn't have a set type, use an associative array.
You may replace typeof(x[0]) with the named type of the elements.