mint.range - Palamecia/mint GitHub Wiki
Module
load mint.range
This module provides a set of functions to perform operations on a range of
elements. The range of elements must implement the in
operator.
Functions
- accumulate
- accumulateIf
- adjacentFind
- allOf
- anyOf
- copy
- copyBackward
- copyIf
- copyN
- count
- countIf
- each
- eachN
- endsWith
- enumerate
- find
- findEnd
- findFirstOf
- findIf
- findIfNot
- iterator
- mismatch
- next
- noneOf
- reverse
- reversed
- search
- searchN
- slice
- startsWith
- transform
- transformIf
- zip
Descriptions
accumulate
def (range, init)
Returns the result of the +
operator applied resursively to each values in
range
where predicate
returns true
for the value with an initial value
of init
.
def (range, init, func)
Returns the result of the func
function applied resursively to each values
in range
where predicate
returns true
for the value with an initial
value of init
.
accumulateIf
def (range, init, predicate)
Returns the result of the +
operator applied resursively to each values in
range
with an initial value of init
.
def (range, init, predicate, func)
Returns the result of the func
function applied resursively to each values
in range
with an initial value of init
.
adjacentFind
def (range)
Returns an iterator on the first element of range
that is equal to its next
element. The elements of range
must implement the ==
operator.
def (range, predicate)
Returns an iterator on the first element of range
where predicate
returns
true
when called with the element and its next element.
allOf
def (range, predicate)
Returns true
if predicate
returns true
for all elements in range
;
otherwie returns false
.
anyOf
def (range, predicate)
Returns true
if predicate
returns true
for at least one element in
range
; otherwie returns false
.
copy
def (range, other)
Copy all elements in other
to the corresponding element of range
. Returns
an iterator on the next element of range
.
copyBackward
def (range, other)
Copy all elements in other
to the corresponding element of range
starting
from the end. Returns a reversed iterator on the next element of range
.
copyIf
def (range, other, predicate)
Copy all elements in other
for which predicate returns true
to the
corresponding element of range
. Returns an iterator on the next element of
range
.
copyN
def (range, n, other)
Copy the n
first elements in other
to the corresponding element of range
.
Returns an iterator on the next element of range
.
count
def (range)
Returns the number of elements in range
.
def (range, value)
Returns the number of elements in range
that is equal to value
. Both
range
elemnts and value
must implement the ==
operator.
countIf
def (range, predicate)
Returns the number of elements in range
for which predicate
returns
true
.
each
def (range, func)
Calls func
for each element in range
.
eachN
def (range, n, func)
Calls func
for the n
first elements in range
.
endsWith
def (range, other)
Returns true
if the last elements of range
are equal to the elements of
other
; otherwise returns false
. The elements of range
and other
must
implement the ==
operator.
def (range, other, predicate)
Returns true
if the last elements of range
are equal to the elements of
other
; otherwise returns false
. The elements of range
and other
are
compared using predicate
.
enumerate
def (range, from = 0)
Returns an iterator containing iterators with a counter starting from from
before each element contained in range
.
find
def (range, value)
Returns an iterator on the first element of range
that match value
. The
elements of range
must implement the ==
operator.
findEnd
def (range, other)
Returns an iterator on the beginning of the last occurence of other
in
range
. The elements of range
and other
must implement the ==
operator.
def (range, other, predicate)
Returns an iterator on the beginning of the last occurence of other
in
range
. The elements of range
and other
are compared using predicate
.
findFirstOf
def (range, values)
Returns an iterator on the first element of range
that is equal to an element
of values
. The elements of range
and values
must implement the ==
operator.
def (range, values, predicate)
Returns an iterator on the first element of range
where predicate
returns
true
for an element of values
.
findIf
def (range, predicate)
Returns an iterator on the first element of range
where predicate
returns
true
.
findIfNot
def (range, predicate)
Returns an iterator on the first element of range
where predicate
returns
false
.
iterator
def ()
Returns an empty iterator.
def (...)
Returns an iterator on each parameter passed to the function.
mismatch
def (range, other)
Returns an iterator containing two iterators on the first non-equal elements
of range
and other
. The elements in the two ranges must implement the ==
operator.
def (range, other, predicate)
Returns an iterator containing two iterators on the first elements of range
and other
where predicate
returns false
.
next
def (range, step = 1)
Returns an iterator starting to the step
th next element in the object
provided by range
.
noneOf
def (range, predicate)
Returns true
if predicate
returns true
for no elements in range
;
otherwie returns false
.
reverse
def (range)
Reverses the order of the elements in range
and returns range
.
reversed
def (range)
Returns an iterator on the elements of range
in reversed order.
search
def (range, other)
Returns an iterator on the beginning of the first occurence of other
in
range
. The elements of range
and other
must implement the ==
operator.
def (range, other, predicate)
Returns an iterator on the beginning of the first occurence of other
in
range
. The elements of range
and other
are compared using predicate
.
searchN
def (range, n, value)
Returns an iterator on the beginning of the first occurence of n
consecutive
elements equals to value
in range
. The elements of range
and value
must implement the ==
operator.
def (range, n, value, predicate)
Returns an iterator on the beginning of the first occurence of n
consecutive
elements equals to value
in range
. The elements of range
and value
are compared using predicate
.
slice
def (range, from, to = none, step = 1)
Returns an iterator on each element contained in range
starting from the
from
th element and until the to
th element. If to
is not specified, the
object provided by the range
parameter must provides a size
method to get
the index of the last inserted value. If step
is provided, elements are
skeeped to provides only elements with an index that is a multiple of step
.
startsWith
def (range, other)
Returns true
if the first elements of range
are equal to the elements of
other
; otherwise returns false
. The elements of range
and other
must
implement the ==
operator.
def (range, other, predicate)
Returns true
if the first elements of range
are equal to the elements of
other
; otherwise returns false
. The elements of range
and other
are
compared using predicate
.
transform
def (range, func)
Returns an iterator containing each result of the func
function applied to
the values contained in range
.
transformIf
def (range, predicate, func)
Returns an iterator containing each result of the func
function applied to
the values contained in range
where predicate
returns true
for the value.
zip
def (range, ...)
Returns an iterator containing, iterators with, for each object passed as parameter, the value contained at the same position.