Use an explicit function argument for iterate

Also replace :hello with "hello" to avoid potential confusion since
:hello is also a function.

refs #75
This commit is contained in:
Colin Jones 2017-10-09 13:16:10 -05:00
parent e74a2664f0
commit 7974120ec3
No known key found for this signature in database
GPG Key ID: BB1DBD3616F1DDB9
2 changed files with 4 additions and 4 deletions

View File

@ -127,7 +127,7 @@
[0 1 2 3 4]
10
95
(range 20)
[1 2 4 8 16 32 64 128]
:a]
"___" [(fn [x] x)]}]

View File

@ -17,12 +17,12 @@
(drop __ (range 100)))
"Iteration provides an infinite lazy sequence"
(= __ (take 20 (iterate inc 0)))
(= __ (take 8 (iterate (fn [x] (* x 2)) 1)))
"Repetition is key"
(= [:a :a :a :a :a :a :a :a :a :a]
(repeat 10 __))
"Iteration can be used for repetition"
(= (repeat 100 :hello)
(take 100 (iterate ___ :hello))))
(= (repeat 100 "hello")
(take 100 (iterate ___ "hello"))))