diff --git a/outline/flow_control.md b/outline/flow_control.md index 92f7a877..40f4c652 100644 --- a/outline/flow_control.md +++ b/outline/flow_control.md @@ -177,7 +177,16 @@ ng-click="block21=!block21"> {: ng-show="block62" .description} ```clojure -(cond +(if (> (+ y 40) 150) ; if over the top + -150 ; then start at the bottom + (if (< (+ y 40) -150) ; if below the bottom + 150 ; then start at the top + (+ y 40))) ; otherwise move + +``` + +```clojure +(cond ; so much more legible than nested ifs (> (+ y 40) 150) -150 (< (+ y 40) -150) 150 :else (+ y 40))) @@ -192,10 +201,24 @@ ng-click="block21=!block21"> predicate1 expression-to-evaluate-when-predicate1-is-true predicate2 expression-to-evaluate-when-predicate2-is-true ... - :else expression-to-evaluate-when-all-above-are-false) + :else expression-to-evaluate-when-all-above-are-false) ``` +
+#### `cond` example + +```clojure +(cond + (< x 10) "x is smaller than 10" + (< 10 x 20) "x is between 10 and 20" + (< 20 x 30) "x is between 20 and 30" + (< 30 x 40) "x is between 30 and 40" + :else "x is bigger than 40") +``` + +
+
#### EXERCISE 2: Y value within a frame - part 2 {: .slide_title .slide}