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:
parent
e74a2664f0
commit
7974120ec3
@ -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)]}]
|
||||
|
||||
|
@ -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"))))
|
||||
|
Loading…
Reference in New Issue
Block a user