diff --git a/README.md b/README.md index 14d486f..6780733 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/liblazy.jl b/src/liblazy.jl index 65704a3..7479879 100644 --- a/src/liblazy.jl +++ b/src/liblazy.jl @@ -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]) @@ -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)) : [] diff --git a/test/runtests.jl b/test/runtests.jl index 89f51b7..f8dec7c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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