1234567891011121314151617181920212223 |
- // break/continue in for loop with label
- (def isum 0)
- (def jsum 0)
- (for outerLoop: [(def i 1) (< i 5) (++ i)]
- //(set isum (+ isum i))
- (set isum (+ isum i))
- (for innerLoop: [(def j 1) (< j 5) (++ j)]
- //(printf "i = %v j = %v\n" i j)
- (set jsum (+ jsum j))
- //(printf " -- after inner increment, jsum is %v\n" jsum)
- (cond (> j 2) (continue outerLoop:)
- (and (> i 2) (> j 3)) (break outerLoop:)
- null)
- //(printf "advancing jsum %v -> %v\n" jsum (+ jsum 1000))
- (set jsum (+ jsum 1000))// check continue works
- )
- )
- //(printf "isum is %d\n" isum)
- //(printf "jsum is %d\n" jsum)
- (assert (== isum 10))
- (assert (== jsum 8024))
|