Set
Definitions
def
count
[aef]
(
f :
a -> Bool \ ef
s :
Set[a]
)
: Int32
\ ef
Returns the number of elements in s that satisfy the predicate f.
Purity reflective: Runs in parallel when given a pure function f.
def
difference
[a]
(
s1 :
Set[a]
s2 :
Set[a]
)
: Set[a]
\ Pure
with
Order[a]
Returns the difference of s1 and s2, i.e. s1 - s2.
def
empty
[a]
: Set[a]
\ Pure
Returns the empty set.
Set#{} is syntactic sugar for empty i.e. Set#{} == empty().
def
enumerator
[ra]
(
rc :
Region[r]
s :
Set[a]
)
: Iterator[(Int32, a), r, r]
\ r
Returns an iterator over s zipped with the indices of the elements.
def
exists
[aef]
(
f :
a -> Bool \ ef
s :
Set[a]
)
: Bool
\ ef
Returns true if and only if at least one element in s satisfies the predicate f.
Returns false if s is the empty set.
def
filter
[aef]
(
f :
a -> Bool \ ef
s :
Set[a]
)
: Set[a]
\ ef
with
Order[a]
Returns the set of all elements of s that satisfy the predicate f.
def
filterMap
[aefb]
(
f :
a -> Option[b] \ ef
s :
Set[a]
)
: Set[b]
\ ef
with
Order[b]
Collects the results of applying the partial function f to every element in s.
def
find
[aef]
(
f :
a -> Bool \ ef
s :
Set[a]
)
: Option[a]
\ ef
Alias for findLeft.
def
findLeft
[aef]
(
f :
a -> Bool \ ef
s :
Set[a]
)
: Option[a]
\ ef
Optionally returns the first element of s that satisfies the predicate f when searching from left to right.
def
findRight
[aef]
(
f :
a -> Bool \ ef
s :
Set[a]
)
: Option[a]
\ ef
Optionally returns the first element of s that satisfies the predicate f when searching from right to left.
def
flatMap
[aefb]
(
f :
a -> Set[b] \ ef
s :
Set[a]
)
: Set[b]
\ ef
with
Order[b]
Returns the result of applying f to every element in s and taking the union.
def
flatten
[a]
(
s :
Set[Set[a]]
)
: Set[a]
\ Pure
with
Order[a]
Returns the union of the elements in s.
def
fold
[a]
(
s :
Set[a]
)
: a
\ Pure
with
Monoid[a]
Returns the result of applying combine to all the elements in s, using empty as the initial value.
def
foldLeft
[baef]
(
f :
b -> (a -> b \ ef)
s :
b
s1 :
Set[a]
)
: b
\ ef
Applies f to a start value s and all elements in s going from left to right.
That is, the result is of the form: f(...f(f(s, x1), x2)..., xn).
def
foldMap
[aefb]
(
f :
a -> b \ ef
s :
Set[a]
)
: b
\ ef
with
Monoid[b]
Returns the result of mapping each element and combining the results.
def
foldRight
[abef]
(
f :
a -> (b -> b \ ef)
s :
b
s1 :
Set[a]
)
: b
\ ef
Applies f to a start value s and all elements in s1 going from right to left.
That is, the result is of the form: f(x1, ...f(xn-1, f(xn, s))...).
def
foldRightWithCont
[aefb]
(
f :
a -> ((Unit -> b \ ef) -> b \ ef)
z :
b
s :
Set[a]
)
: b
\ ef
Applies f to a start value z and all elements in s going from right to left.
That is, the result is of the form: f(x1, ...f(xn-1, f(xn, z))...).
A foldRightWithCont allows early termination by not calling the continuation.
def
forAll
[aef]
(
f :
a -> Bool \ ef
s :
Set[a]
)
: Bool
\ ef
Returns true if and only if all elements in s satisfy the predicate f.
Returns true if s is the empty set.
def
forEach
[aef]
(
f :
a -> Unit \ ef
s :
Set[a]
)
: Unit
\ ef
Applies f to every element of s.
def
forEachWithIndex
[aef]
(
f :
Int32 -> (a -> Unit \ ef)
s :
Set[a]
)
: Unit
\ ef
Applies f to every element of s along with that element's index.
def
insert
[a]
(
x :
a
s :
Set[a]
)
: Set[a]
\ Pure
with
Order[a]
Adds x to s.
def
intersection
[a]
(
s1 :
Set[a]
s2 :
Set[a]
)
: Set[a]
\ Pure
with
Order[a]
Returns the intersection of s1 and s2.
def
isEmpty
[a]
(
s :
Set[a]
)
: Bool
\ Pure
Returns true if and only if s is the empty set.
def
isProperSubsetOf
[a]
(
s1 :
Set[a]
s2 :
Set[a]
)
: Bool
\ Pure
with
Order[a]
Returns true if and only if every element in s1 appears in s2 and s != s2.
def
isSubsetOf
[a]
(
s1 :
Set[a]
s2 :
Set[a]
)
: Bool
\ Pure
with
Order[a]
Returns true if and only if every element in s1 appears in s2.
def
iterator
[ra]
(
rc :
Region[r]
s :
Set[a]
)
: Iterator[a, r, r]
\ r
Returns an iterator over s.
def
join
[a]
(
sep :
String
s :
Set[a]
)
: String
\ Pure
with
ToString[a]
Returns the concatenation of the string representation
of each element in s with sep inserted between each element.
def
joinWith
[aef]
(
f :
a -> String \ ef
sep :
String
s :
Set[a]
)
: String
\ ef
Returns the concatenation of the string representation
of each element in s according to f with sep inserted between each element.
def
map
[aefb]
(
f :
a -> b \ ef
s :
Set[a]
)
: Set[b]
\ ef
with
Order[b]
Returns the result of applying f to every element in s.
Note: The returned set may be smaller than s.
def
maximum
[a]
(
s :
Set[a]
)
: Option[a]
\ Pure
Optionally finds the largest element of s according to the Order on a.
Returns None if s is empty.
def
maximumBy
[aef]
(
cmp :
a -> (a -> Comparison \ ef)
s :
Set[a]
)
: Option[a]
\ ef
Optionally finds the largest element of s according to the given comparator cmp.
Returns None if s is empty.
Purity reflective: Runs in parallel when given a pure function f.
def
memberOf
[a]
(
x :
a
s :
Set[a]
)
: Bool
\ Pure
with
Order[a]
Returns true if and only if x is a member of s.
def
minimum
[a]
(
s :
Set[a]
)
: Option[a]
\ Pure
Optionally finds the smallest element of s according to the Order on a.
Returns None if s is empty.
def
minimumBy
[aef]
(
cmp :
a -> (a -> Comparison \ ef)
s :
Set[a]
)
: Option[a]
\ ef
Optionally finds the smallest element of s according to the given comparator cmp.
Returns None if s is empty.
Purity reflective: Runs in parallel when given a pure function f.
def
partition
[aef]
(
f :
a -> Bool \ ef
s :
Set[a]
)
: (Set[a], Set[a])
\ ef
with
Order[a]
Returns a pair of sets (s1, s2).
s1 contains all elements of s that satisfy the predicate f.
s2 contains all elements of s that do not satisfy the predicate f.
def
range
(
b :
Int32
e :
Int32
)
: Set[Int32]
\ Pure
Returns a set of all integers between b (inclusive) and e (exclusive).
Returns empty() if b >= e.
def
reduceLeft
[aef]
(
f :
a -> (a -> a \ ef)
s :
Set[a]
)
: Option[a]
\ ef
Applies f to all elements in s going from left to right until a single value v is obtained. Returns Some(v).
That is, the result is of the form: Some(f(...f(f(x1, x2), x3)..., xn))
Returns None if s is the empty set.
def
reduceRight
[aef]
(
f :
a -> (a -> a \ ef)
s :
Set[a]
)
: Option[a]
\ ef
Applies f to all elements in s going from right to left until a single value v is obtained. Returns Some(v).
That is, the result is of the form: Some(f(x1, ...f(xn-2, f(xn-1, xn))...))
Returns None if s is the empty set.
def
remove
[a]
(
x :
a
s :
Set[a]
)
: Set[a]
\ Pure
with
Order[a]
Removes x from s.
def
replace
[a]
(
from :
{ from = a }
to :
{ to = a }
s :
Set[a]
)
: Set[a]
\ Pure
with
Order[a]
Replaces the element from with to if from is in s. Otherwise, returns s.
Note: The returned set may be smaller than s.
def
singleton
[a]
(
x :
a
)
: Set[a]
\ Pure
with
Order[a]
Returns the singleton set containing x.
Set#{x} is syntactic sugar for singleton i.e. Set#{x} == singleton(x).
def
size
[a]
(
s :
Set[a]
)
: Int32
\ Pure
Returns the size of s.
def
subsets
[a]
(
s :
Set[a]
)
: Set[Set[a]]
\ Pure
with
Order[a]
Returns all subsets of s.
def
sum
(
s :
Set[Int32]
)
: Int32
\ Pure
Returns the sum of all elements in the set s.
def
sumWith
[aef]
(
f :
a -> Int32 \ ef
s :
Set[a]
)
: Int32
\ ef
Returns the sum of all elements in the set s according to the function f.
Purity reflective: Runs in parallel when given a pure function f.
def
toChain
[a]
(
s :
Set[a]
)
: Chain[a]
\ Pure
Returns the set s as a chain.
def
toDelayList
[a]
(
s :
Set[a]
)
: DelayList[a]
\ Pure
Returns the set s as a DelayList.
def
toList
[a]
(
s :
Set[a]
)
: List[a]
\ Pure
Returns the set s as a list.
def
toMap
[ab]
(
s :
Set[(a, b)]
)
: Map[a, b]
\ Pure
with
Order[a]
Returns the association set s as a map.
If s contains multiple mappings with the same key, toMap does not
make any guarantees about which mapping will be in the resulting map.
def
toMapWith
[ab]
(
f :
a -> b
s :
Set[a]
)
: Map[a, b]
\ Pure
with
Order[a]
Returns a map with elements of s as keys and f applied as values.
def
toMutDeque
[ra]
(
rc :
Region[r]
s :
Set[a]
)
: MutDeque[a, r]
\ r
Returns s as a MutDeque.
def
toMutSet
[ra]
(
rc :
Region[r]
s :
Set[a]
)
: MutSet[a, r]
\ r
Returns the set s as a MutSet.
def
toString
[a]
(
s :
Set[a]
)
: String
\ Pure
with
ToString[a]
Returns a string representation of the given set s.
def
unfold
[sefa]
(
f :
s -> Option[(a, s)] \ ef
st :
s
)
: Set[a]
\ ef
with
Order[a]
Build a set by applying f to the seed value st.
f should return Some(a,st1) to signal a new set element a and a new seed value st1.
f should return None to signal the end of building the set.
def
unfoldWithIter
[efa]
(
next :
Unit -> Option[a] \ ef
)
: Set[a]
\ ef
with
Order[a]
Build a set by applying the function next to (). next is expected to encapsulate
a stateful resource such as a file handle that can be iterated.
next should return Some(a) to signal a value pair a.
next should return None to signal the end of building the set.
def
union
[a]
(
s1 :
Set[a]
s2 :
Set[a]
)
: Set[a]
\ Pure
with
Order[a]
Returns the union of s1 and s2.