Logo

Programming-Idioms

# 363 Set to list
Create the list y from the set x.

The resulting list y may be in any order.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
y := make([]T, 0, len(x))
for v := range x {
	y = append(y, v)
}
import "maps"
import "slices"
y := slices.Collect(maps.Keys(x))
fgl
Type
  TSet = set of T;
  TList = specialize TFPGList<T>;
var
  x: TSet;
  y: TList;
  item: T;
begin
...
  y := TList.Create;
  for item in x do y.Add(item);
...
y = list(x)
y = x.to_a