Methods
(static) accumulate(iterable, func)
左側からの畳み込みを行った結果をIterableオブジェクトとして返却する。
Haskellのscanlに近いが、初期値としては配列の最初の要素が用いられる。 したがって、関数は型 a -> a -> aを持つ必要がある。
Parameters:
Name | Type | Description |
---|---|---|
iterable |
Iterable | |
func |
function |
- Source:
Example
Itertools.accumulate([1,2,3,4,5]) // [1,3,6,10,15]
Itertools.accumulate([1,2,3,4,5], (a,b) => a*b) // [1,2,6,24,120]
(static) count(start, step) → {Iterable}
指定した値から開始する等差数列のIterableオブジェクトを返却する。
Parameters:
Name | Type | Default | Description |
---|---|---|---|
start |
number | ||
step |
number | 1 | [Optional] 刻み幅を指定する。デフォルトは1. |
- Source:
Returns:
- Type
- Iterable
(static) cycle(elements) → {Iterable}
引数のIterableオブジェクトを繰り返すIterableオブジェクトを返却する。
Parameters:
Name | Type | Description |
---|---|---|
elements |
array | 配列やIterableオブジェクト |
- Source:
Returns:
- Type
- Iterable
(static) range(start, end, step) → {Iterable}
[start,end)
Parameters:
Name | Type | Default | Description |
---|---|---|---|
start |
number | ||
end |
number | ||
step |
number | 1 |
- Source:
Returns:
- Type
- Iterable
(static) repeat(value) → {Iterable}
引数の値を繰り返すIterableオブジェクトを返却する。
Parameters:
Name | Type | Description |
---|---|---|
value |
* | Iterableオブジェクトが生成する値 |
- Source:
Returns:
- Type
- Iterable