Pages
Standard Library

Search
Entities

# Set

## Functions

add
(
set
:
Set(item)
value
:
item
)
:
Set(item)

Adds the given value to the set.

``````(Set.empty()
|> Set.add("value")) == Set.fromArray(["value"])
``````
delete
(
set
:
Set(item)
value
:
item
)
:
Set(item)

Deletes the given value from the set.

``````(Set.empty()
|> Set.add("value")
|> Set.delete("value")) == Set.empty()
``````
empty
:
Set(item)

Returns an empty set.

fromArray
(
array
:
Array(item)
)
:
Set(item)

Converts an Array to a Set.

``````(Set.empty()
|> Set.add("value")) == Set.fromArray(["value"])
``````
has
(
set
:
Set(item)
value
:
item
)
:
Bool

Returns whether or not the given set has the given value.

``````(Set.empty()
|> Set.add(Maybe.just("value"))
|> Set.has(Maybe.just("value"))) == true
``````
map
(
set
:
Set(item)
method
:
Function(item, b)
)
:
Set(b)

Maps over the items of the set to return a new set.

``````(Set.fromArray([0])
|> Set.map(Number.toString)) == Set.fromArray(["0"])
``````
size
(
set
:
Set(item)
)
:
Number

Returns the size of a set

``````Set.size(Set.fromArray([0,1,2])) == 3
``````
toArray
(
set
:
Set(item)
)
:
Array(item)

Converts the Set to an Array.

``````(Set.empty()
|> Set.add("value")
|> Set.toArray()) == ["value"]
``````