Logo

Programming-Idioms

Insert an element e into the set x.
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
#include <set>
x.insert(e);
x.add(e);
x[e] = true
x[e] = struct{}{}
x.add(e);
import java.util.Set;
x.add(e)
x[e] = true
Include(x,e);
x := x + [e];
use Set::Scalar;
$x = Set::Scalar->new;
$e = 'an element';
$x->insert($e);
x.add(e)
require 'set'
x.add(e)
x << e
use std::collections::HashSet
x.insert(e);