Skip to content

Latest commit

 

History

History
executable file
·
519 lines (421 loc) · 8.8 KB

new_sets_doc.md

File metadata and controls

executable file
·
519 lines (421 loc) · 8.8 KB

sets.make

sets.make(elements)

Creates a new set.

All elements must be hashable.

Parameters

elements optional. default is None

Optional sequence to construct the set out of.

sets.copy

sets.copy(s)

Creates a new set from another set.

Parameters

s required.

A set, as returned by `sets.make()`.

sets.to_list

sets.to_list(s)

Creates a list from the values in the set.

Parameters

s required.

A set, as returned by `sets.make()`.

sets.insert

sets.insert(s, e)

Inserts an element into the set.

Element must be hashable. This mutates the original set.

Parameters

s required.

A set, as returned by `sets.make()`.

e required.

The element to be inserted.

sets.contains

sets.contains(a, e)

Checks for the existence of an element in a set.

Parameters

a required.

A set, as returned by `sets.make()`.

e required.

The element to look for.

sets.is_equal

sets.is_equal(a, b)

Returns whether two sets are equal.

Parameters

a required.

A set, as returned by `sets.make()`.

b required.

A set, as returned by `sets.make()`.

sets.is_subset

sets.is_subset(a, b)

Returns whether a is a subset of b.

Parameters

a required.

A set, as returned by `sets.make()`.

b required.

A set, as returned by `sets.make()`.

sets.disjoint

sets.disjoint(a, b)

Returns whether two sets are disjoint.

Two sets are disjoint if they have no elements in common.

Parameters

a required.

A set, as returned by `sets.make()`.

b required.

A set, as returned by `sets.make()`.

sets.intersection

sets.intersection(a, b)

Returns the intersection of two sets.

Parameters

a required.

A set, as returned by `sets.make()`.

b required.

A set, as returned by `sets.make()`.

sets.union

sets.union(args)

Returns the union of several sets.

Parameters

args optional.

An arbitrary number of sets or lists.

sets.difference

sets.difference(a, b)

Returns the elements in a that are not in b.

Parameters

a required.

A set, as returned by `sets.make()`.

b required.

A set, as returned by `sets.make()`.

sets.length

sets.length(s)

Returns the number of elements in a set.

Parameters

s required.

A set, as returned by `sets.make()`.

sets.remove

sets.remove(s, e)

Removes an element from the set.

Element must be hashable. This mutates the original set.

Parameters

s required.

A set, as returned by `sets.make()`.

e required.

The element to be removed.

sets.repr

sets.repr(s)

Returns a string value representing the set.

Parameters

s required.

A set, as returned by `sets.make()`.

sets.str

sets.str(s)

Returns a string value representing the set.

Parameters

s required.

A set, as returned by `sets.make()`.