Finished eleventh koan
This commit is contained in:
parent
bbfe379b22
commit
3e761f927a
1 changed files with 7 additions and 7 deletions
|
|
@ -3,26 +3,26 @@
|
||||||
|
|
||||||
(meditations
|
(meditations
|
||||||
"There are many ways to generate a sequence"
|
"There are many ways to generate a sequence"
|
||||||
(= __ (range 1 5))
|
(= '(1 2 3 4) (range 1 5))
|
||||||
|
|
||||||
"The range starts at the beginning by default"
|
"The range starts at the beginning by default"
|
||||||
(= __ (range 5))
|
(= '(0 1 2 3 4) (range 5))
|
||||||
|
|
||||||
"Only take what you need when the sequence is large"
|
"Only take what you need when the sequence is large"
|
||||||
(= [0 1 2 3 4 5 6 7 8 9]
|
(= [0 1 2 3 4 5 6 7 8 9]
|
||||||
(take __ (range 100)))
|
(take 10 (range 100)))
|
||||||
|
|
||||||
"Or limit results by dropping what you don't need"
|
"Or limit results by dropping what you don't need"
|
||||||
(= [95 96 97 98 99]
|
(= [95 96 97 98 99]
|
||||||
(drop __ (range 100)))
|
(drop 95 (range 100)))
|
||||||
|
|
||||||
"Iteration provides an infinite lazy sequence"
|
"Iteration provides an infinite lazy sequence"
|
||||||
(= __ (take 8 (iterate (fn [x] (* x 2)) 1)))
|
(= '(1 2 4 8 16 32 64 128) (take 8 (iterate (fn [x] (* x 2)) 1)))
|
||||||
|
|
||||||
"Repetition is key"
|
"Repetition is key"
|
||||||
(= [:a :a :a :a :a :a :a :a :a :a]
|
(= [:a :a :a :a :a :a :a :a :a :a]
|
||||||
(repeat 10 __))
|
(repeat 10 :a))
|
||||||
|
|
||||||
"Iteration can be used for repetition"
|
"Iteration can be used for repetition"
|
||||||
(= (repeat 100 "hello")
|
(= (repeat 100 "hello")
|
||||||
(take 100 (iterate ___ "hello"))))
|
(take 100 (iterate str "hello"))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue