Skip to content

Commit

Permalink
iterate -> iterated
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeInnes committed Jun 5, 2018
1 parent 590faa2 commit db5a0eb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ cycle(a) == (a... a... a... ...)
cycle([1,2,3]) == (1 2 3 1 2 3 1 2 3 1 ...)

# Repeatedly nest function calls
iterate(f, x) == (x f(x) f(f(x)) ...)
iterate(x->x^2, 2) == (2 4 16 256 65536 ...)
iterated(f, x) == (x f(x) f(f(x)) ...)
iterated(x->x^2, 2) == (2 4 16 256 65536 ...)

range(2) == (2 3 4 5 ...)
range(1, 5) == (1 2 3 4 5)
Expand Down
4 changes: 2 additions & 2 deletions src/liblazy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Construction
# ------------

export seq, constantly, repeatedly, iterate, concat
export seq, constantly, repeatedly, iterated, concat

seq(xs::List) = xs
seq(xs::Array) = isempty(xs) ? list() : xs[1]:seq(xs[2:end])
Expand All @@ -24,7 +24,7 @@ cycle(xs) = @lazy xs * cycle(xs)
repeatedly(f) = @lazy f():repeatedly(f)
repeatedly(n, f) = @>> repeatedly(f) take(n)

iterate(f, v) = @lazy v:iterate(f, f(v))
iterated(f, v) = @lazy v:iterated(f, f(v))

range(x, y, step=1) =
@lazy x <= y ? (x:range(x+step, y, step)) : []
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using Base.Test
testfn() = 1
@test repeatedly(testfn)[50] == 1
@test cycle([1, 2, 3])[50] == 2
@test iterate(x->x^2, 2)[3] == 16
@test iterated(x->x^2, 2)[3] == 16
@test range(1, 5)[3] == 3
@test range(1, 5)[10] == nothing
@test range(1, 5)[-1] == 1
Expand Down

0 comments on commit db5a0eb

Please sign in to comment.