Iterable[T]
Abstract type for iterable values, whose instances have the methods below.
Arrays, dicts, and ranges are Iterable; a Record, or a
class that only implements (iter), is not.
Implements: BaseIterable[T], Spread[T]
Methods
all … -> Bool
Tests whether every item is truthy, or satisfies pred.
Parameters
| Name | Type | Description |
|---|---|---|
pred? |
((T) -> Value) |
any … -> Bool
Tests whether any item is truthy, or satisfies pred.
Parameters
| Name | Type | Description |
|---|---|---|
pred? |
((T) -> Value) |
chain[...Us] ...values -> Iter[Union[T, ...Us]]
Returns an iterator followed by the additional iterables.
Parameters
| Name | Type | Description |
|---|---|---|
...values |
...Iterable[Us] |
chomp[U @ (Str | Bin)]() -> Iter[U]
Returns an iterator with one trailing line terminator removed from each item.
Parameters
| Name | Type | Description |
|---|---|---|
self |
Iterable[U] |
Receiver. |
crimp[U @ (Str | Bin)] … -> Iter[U]
Returns an iterator with a line terminator appended to each item.
Parameters
| Name | Type | Description |
|---|---|---|
self |
Iterable[U] |
Receiver. |
terminator? |
(Str | Bin) |
enumerate() -> Iter[Tuple[Int, T]]
Returns an iterator of [index, value] tuples.
filter pred -> Iter[T]
Returns an iterator of values for which pred is truthy.
Parameters
| Name | Type | Description |
|---|---|---|
pred |
((T) -> Value) |
find[D = T] pred … -> (T | D)
Returns the first value for which pred is truthy.
Parameters
| Name | Type | Description |
|---|---|---|
pred |
((T) -> Value) |
|
:default? |
D |
|
:else? |
(() -> D) |
fold[A] init func -> A
Accumulates a value left-to-right with func.
Parameters
| Name | Type | Description |
|---|---|---|
init |
A |
|
func |
((A, T) -> A) |
iter() -> Iter[T]
Returns an iterator over the value.
map[U] func -> Iter[U]
Returns an iterator that maps each item through func.
Parameters
| Name | Type | Description |
|---|---|---|
func |
((T) -> U) |
max[D = T] … -> (T | D)
Returns the largest item.
Parameters
| Name | Type | Description |
|---|---|---|
:default? |
D |
min[D = T] … -> (T | D)
Returns the smallest item.
Parameters
| Name | Type | Description |
|---|---|---|
:default? |
D |
skip n -> Iter[T]
Returns an iterator that discards the first n items.
Parameters
| Name | Type | Description |
|---|---|---|
n |
Int |
take n -> Iter[T]
Returns an iterator yielding at most n items.
Parameters
| Name | Type | Description |
|---|---|---|
n |
Int |
zip[...Us] ...values -> Iter[Tuple[T, ...Us]]
Returns an iterator of tuples across this and additional iterables.
Parameters
| Name | Type | Description |
|---|---|---|
...values |
...Iterable[Us] |