Skip to content

Commit e96ccc4

Browse files
kylevtrptcolin
authored andcommitted
Switch variable from index to x to avoid confusing syntax highlightig.
index is a clojure.set function and ended up highlighted for me, sending me down a rabbit hole of confusion. Avoid this with a more generic variable name consistent with other Koan files.
1 parent 660998a commit e96ccc4

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/koans/11_sequence_comprehensions.clj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
(meditations
22
"Sequence comprehensions can bind each element in turn to a symbol"
33
(= __
4-
(for [index (range 6)]
5-
index))
4+
(for [x (range 6)]
5+
x))
66

77
"They can easily emulate mapping"
88
(= '(0 1 4 9 16 25)
9-
(map (fn [index] (* index index))
9+
(map (fn [x] (* x x))
1010
(range 6))
11-
(for [index (range 6)]
11+
(for [x (range 6)]
1212
__))
1313

1414
"And also filtering"
1515
(= '(1 3 5 7 9)
1616
(filter odd? (range 10))
17-
(for [index __ :when (odd? index)]
18-
index))
17+
(for [x __ :when (odd? x)]
18+
x))
1919

2020
"Combinations of these transformations is trivial"
2121
(= '(1 9 25 49 81)
22-
(map (fn [index] (* index index))
22+
(map (fn [x] (* x x))
2323
(filter odd? (range 10)))
24-
(for [index (range 10) :when __]
24+
(for [x (range 10) :when __]
2525
__))
2626

2727
"More complex transformations simply take multiple binding forms"

0 commit comments

Comments
 (0)