Loops/Foreach: Difference between revisions

Content added Content deleted
(added Julia example)
(added Julia example)
Line 833: Line 833:
*/</lang>
*/</lang>


{{trans|Julia}}
=={{header|Julia}}==
{{trans|Python}}
<lang julia>for i in collection
<lang julia>for i in collection
println(i)
println(i)
end</lang>
end</lang>
The Julia <code>for</code> statement is always a "foreach", and the built-in <code>start:end</code> or <code>start:step:end</code> "range" syntax can be used for iteration over arithmetic sequences. Many Julia objects support iteration: arrays and tuples iterate over each item, strings iterate over each character, dictionaries iterate over (key,value) pairs, numeric scalars provide a length-1 iteration over their value, and so on.
The Julia <code>for</code> statement is always a "foreach", and the built-in <code>start:end</code> or <code>start:step:end</code> "range" syntax can be used for iteration over arithmetic sequences. Many Julia objects support iteration: arrays and tuples iterate over each item, strings iterate over each character, dictionaries iterate over (key,value) pairs, numeric scalars provide a length-1 iteration over their value, and so on.


=={{header|Lasso}}==
=={{header|Lasso}}==