Module

Webb.Set

Package
purescript-webb-set
Repository
mitchellandwebb/webb-set

#toArray Source

toArray :: forall k. Set k -> Array k

#fromArray Source

fromArray :: forall k. Ord k => Array k -> Set k

#reject Source

reject :: forall k. Ord k => (k -> Boolean) -> Set k -> Set k

#WSet Source

type WSet a = Set a

Re-exports from Data.Set

#Set Source

newtype Set a

Set a represents a set of values of type a

Instances

#unions Source

unions :: forall f a. Foldable f => Ord a => f (Set a) -> Set a

Form the union of a collection of sets

#union Source

union :: forall a. Ord a => Set a -> Set a -> Set a

Form the union of two sets

Running time: O(n + m)

#toggle Source

toggle :: forall a. Ord a => a -> Set a -> Set a

Insert a value into a set if it is not already present, if it is present, delete it.

#toUnfoldable Source

toUnfoldable :: forall f a. Unfoldable f => Set a -> f a

Convert a set to an unfoldable structure.

#toMap Source

toMap :: forall a. Set a -> Map a Unit

A set is a map with no value attached to each key.

#subset Source

subset :: forall a. Ord a => Set a -> Set a -> Boolean

True if and only if every element in the first set is an element of the second set

#size Source

size :: forall a. Set a -> Int

Find the size of a set

#singleton Source

singleton :: forall a. a -> Set a

Create a set with one element

#properSubset Source

properSubset :: forall a. Ord a => Set a -> Set a -> Boolean

True if and only if the first set is a subset of the second set and the sets are not equal

#member Source

member :: forall a. Ord a => a -> Set a -> Boolean

Test if a value is a member of a set

#mapMaybe Source

mapMaybe :: forall a b. Ord b => (a -> Maybe b) -> Set a -> Set b

Applies a function to each value in a set, discarding entries where the function returns Nothing.

#map Source

map :: forall a b. Ord b => (a -> b) -> Set a -> Set b

Maps over the values in a set.

This operation is not structure-preserving for sets, so is not a valid Functor. An example case: mapping const x over a set with n > 0 elements will result in a set with one element.

#isEmpty Source

isEmpty :: forall a. Set a -> Boolean

Test if a set is empty

#intersection Source

intersection :: forall a. Ord a => Set a -> Set a -> Set a

The set of elements which are in both the first and second set

#insert Source

insert :: forall a. Ord a => a -> Set a -> Set a

Insert a value into a set

#fromMap Source

fromMap :: forall a. Map a Unit -> Set a

A map with no value attached to each key is a set. See also Data.Map.keys.

#fromFoldable Source

fromFoldable :: forall f a. Foldable f => Ord a => f a -> Set a

Create a set from a foldable structure.

#findMin Source

findMin :: forall a. Set a -> Maybe a

#findMax Source

findMax :: forall a. Set a -> Maybe a

#filter Source

filter :: forall a. Ord a => (a -> Boolean) -> Set a -> Set a

Filter out those values of a set for which a predicate on the value fails to hold.

#empty Source

empty :: forall a. Set a

An empty set

#difference Source

difference :: forall a. Ord a => Set a -> Set a -> Set a

Form the set difference

#delete Source

delete :: forall a. Ord a => a -> Set a -> Set a

Delete a value from a set

#checkValid Source

checkValid :: forall a. Ord a => Set a -> Boolean

Check whether the underlying tree satisfies the height, size, and ordering invariants.

This function is provided for internal use.

#catMaybes Source

catMaybes :: forall a. Ord a => Set (Maybe a) -> Set a

Filter a set of optional values, discarding values that contain Nothing

Modules
Webb.Set