Jump to content

Loops/For with a specified step: Difference between revisions

Add Clojure
m (→‎{{header|Perl 6}}: more 'series' --> 'sequence', sorry 'bout the noise)
(Add Clojure)
Line 111:
}
}</lang>
 
=={{header|Clojure}}==
The first example here is following the literal specification, but is not idiomatic Clojure code. The second example achieves the same effect without explicit looping, and would (I think) be viewed as better code by the Clojure community.
<lang Clojure>(loop [i 0]
(println i)
(when (< i 10)
(recur (+ 2 i))))
 
(doseq [i (range 0 12 2)]
(println i))</lang>
 
=={{header|Common Lisp}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.