↑ Up |
Functions that create iterators.
iter(iterables.sum(list))
.
> chain(1..2,1..4).list() [1, 2, 1, 2, 3, 4]
> prod(["x","y"],[0,1]).list() [["x", 0], ["x", 1], ["y", 0], ["y", 1]]
a
.
The permuations are emitted in lexicographical order.
> permutations("abc").map(|t| t.join()).join("|") "abc|bac|bca|acb|cab|cba"
k
length
combinations of a
. The combinations are emitted
in lexicographical order.
x
over and over
again. If n
is given, the iterator will be exhausted
after n
calls.
a.step(m).list() == [a[0],a[m],a[2*m],...]
Functional programming.
fib = fix({},|f,n| 1 if n==1 or n==2 else f(n-1)+f(n-2)) fib = fix({1: 1, 2: 1}, |f,n| f(n-1)+f(n-2))
x
is done by x.value()
.
The expression is evaluated only once, the result then memoized for
subsequent calls.