diff --git a/resources/public/tutorial.html b/resources/public/tutorial.html index f2e0e08..6ef0fdb 100644 --- a/resources/public/tutorial.html +++ b/resources/public/tutorial.html @@ -651,11 +651,27 @@ comprehension. This is a very powerful construct, and we'll see more of it later.
+
+ Let's use for to calculate all the possible scores for two dice.
+
+
+ (for [x (range 1 7) y (range 1 7)] (+ x y))
+
+
+
+ The first argument of for must be a vector with an even number of forms,
+ and the second is a function. The elements of the vector come in pairs: label then
+ sequence of values which will be assigned to the label. Thus in this
+ case the label x will assigned the values 1, then 2 then 3
(defn row-render-values [grid row]
- (for [col (range 1 10) :let [cell (str row col)]]
- (render-cell (get grid (cell-index cell)))))
+ (for [col (range 1 10)]
+ (let [cell (str row col)]
+ (render-cell (get grid (cell-index cell))))))
@@ -665,7 +681,7 @@
Now, we need to partition these values into groups of 3 and
- interpose pipe symbols. Luckily, Clojure comes with partiiton
+ interpose pipe symbols. Luckily, Clojure comes with partition
and interpose functions! Try: