Jump to content

Loops/Foreach: Difference between revisions

Add CLU
(→‎{{header|ALGOL 68}}: Added note about ALGOL 68RS and algol68toc)
(Add CLU)
Line 887:
=={{header|Clojure}}==
<lang lisp>(doseq [item collection] (println item))</lang>
 
=={{header|CLU}}==
 
As in Python (which no doubt got the idea from CLU), every <em>for</em> loop in
CLU is really a <em>foreach</em>, and iterating over a range of numbers is done
by using an iterator (e.g. <code>int$from_to</code>).
 
Unlike Python, the <em>for</em> loop '''only''' accepts iterators, and collections
are not automatically cast into iterators. To loop over the elements of an array,
one needs to explicitly use the <code>elements</code> iterator.
 
<lang clu>start_up = proc ()
po: stream := stream$primary_output()
words: array[string] := array[string]$
["enemy", "lasagna", "robust", "below", "wax"]
for word: string in array[string]$elements(words) do
stream$putl(po, word)
end
end start_up</lang>
 
=={{header|CMake}}==
2,114

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.