<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://miniscript.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LPopoca</id>
	<title>MiniScript Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://miniscript.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=LPopoca"/>
	<link rel="alternate" type="text/html" href="http://miniscript.org/wiki/Special:Contributions/LPopoca"/>
	<updated>2026-05-03T22:37:56Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>http://miniscript.org/w/index.php?title=For&amp;diff=973</id>
		<title>For</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=For&amp;diff=973"/>
		<updated>2022-05-18T01:32:09Z</updated>

		<summary type="html">&lt;p&gt;LPopoca: Added new when to use for loops and how to create them. Added the nested for loop example. Added outputs in text.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;c&amp;gt;for&amp;lt;/c&amp;gt; is a [[:Category:Keywords|keyword]] used to loop over a sequence (i.e. a [[list]], [[map]], or [[string]]).&lt;br /&gt;
&lt;br /&gt;
[[Category:Language]]&lt;br /&gt;
[[Category:Keywords]]&lt;br /&gt;
&lt;br /&gt;
== When to use for loops ==&lt;br /&gt;
A for loop is used when you want to repeat a block of code a fixed number of times.&lt;br /&gt;
For loops in Miniscript utilize the for each construct.&lt;br /&gt;
Instead of initializing a counter in the for loop statement the for each construct iterates a variable &lt;br /&gt;
over a sequence, this mitigates the risk of creating an off by one error.&lt;br /&gt;
&lt;br /&gt;
== How to create for loops ==&lt;br /&gt;
For loops are created with the &amp;lt;c&amp;gt;for&amp;lt;/c&amp;gt; keyword followed by ''element'' &amp;lt;c&amp;gt;in&amp;lt;/c&amp;gt; ''sequence''.&lt;br /&gt;
For loops are closed off with an &amp;lt;c&amp;gt;end for&amp;lt;/c&amp;gt; keyword statement.&lt;br /&gt;
All code that is to be repeated must be indented in between the &amp;lt;c&amp;gt;for&amp;lt;/c&amp;gt; and &amp;lt;c&amp;gt; end for&amp;lt;/c&amp;gt; statements.&lt;br /&gt;
&lt;br /&gt;
== Iterate over a range of numbers ==&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;ms&amp;gt;&lt;br /&gt;
for i in range(1,3)&lt;br /&gt;
    print i&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/ms&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
'''outputs:'''&lt;br /&gt;
&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Iterate over a list ==&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;ms&amp;gt;&lt;br /&gt;
words = [&amp;quot;hello&amp;quot;, &amp;quot;MiniScript&amp;quot;, &amp;quot;wiki&amp;quot;]&lt;br /&gt;
for word in words&lt;br /&gt;
    print word&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/ms&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
'''outputs:'''&lt;br /&gt;
&lt;br /&gt;
hello&lt;br /&gt;
&lt;br /&gt;
MiniScript&lt;br /&gt;
&lt;br /&gt;
wiki&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Nested For Loops ==&lt;br /&gt;
For loops can be nest inside one another the inner most loop will loop through all its iterations for every iteration the  its outer loop has.&lt;br /&gt;
=== Example ===&lt;br /&gt;
&amp;lt;ms&amp;gt;&lt;br /&gt;
for i in range(1,2)&lt;br /&gt;
	for j in range(3,4)&lt;br /&gt;
		print val(i) + &amp;quot; + &amp;quot; + val(j) + &amp;quot; = &amp;quot; + val(i+j)&lt;br /&gt;
	end for&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/ms&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
'''outputs:'''&lt;br /&gt;
&lt;br /&gt;
1 + 3 = 4&lt;br /&gt;
&lt;br /&gt;
1 + 4 = 5&lt;br /&gt;
&lt;br /&gt;
2 + 3 = 5&lt;br /&gt;
&lt;br /&gt;
2 + 4 = 6&lt;/div&gt;</summary>
		<author><name>LPopoca</name></author>
		
	</entry>
	<entry>
		<id>http://miniscript.org/w/index.php?title=For&amp;diff=972</id>
		<title>For</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=For&amp;diff=972"/>
		<updated>2022-05-08T01:06:15Z</updated>

		<summary type="html">&lt;p&gt;LPopoca: Created an example for iterating over a range of numbers and an example of iterating over a list.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;c&amp;gt;for&amp;lt;/c&amp;gt; is a [[:Category:Keywords|keyword]] used to loop over a sequence (i.e. a [[list]], [[map]], or [[string]]).&lt;br /&gt;
&lt;br /&gt;
[[Category:Language]]&lt;br /&gt;
[[Category:Keywords]]&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Iterate over a range of numbers&lt;br /&gt;
&amp;lt;ms&amp;gt;&lt;br /&gt;
for i in range(1,10)&lt;br /&gt;
    print i&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/ms&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Iterate over a list&lt;br /&gt;
&amp;lt;ms&amp;gt;&lt;br /&gt;
words = [&amp;quot;hello&amp;quot;, &amp;quot;MiniScript&amp;quot;, &amp;quot;wiki&amp;quot;]&lt;br /&gt;
for word in words&lt;br /&gt;
    print word&lt;br /&gt;
end for&lt;br /&gt;
&amp;lt;/ms&amp;gt;&lt;/div&gt;</summary>
		<author><name>LPopoca</name></author>
		
	</entry>
</feed>