100 doors: Difference between revisions

Content added Content deleted
(→‎{{header|ALGOL 60}}: Syntax highlight with Mediawiki markup)
(→‎{{header|Euler}}: Use Mediawiki markup for syntax highlighting)
Line 5,389: Line 5,389:
=={{header|Euler}}==
=={{header|Euler}}==
In Euler, all variables have the value <code>undefined</code> until assigned another value. <code>isu x</code> returns <code>true</code> if x is currently undefined and the and/or operators short-circuit.
In Euler, all variables have the value <code>undefined</code> until assigned another value. <code>isu x</code> returns <code>true</code> if x is currently undefined and the and/or operators short-circuit.
'''begin''' '''new''' doors; '''new''' i; '''label''' doorLoop; '''label''' outDoors;
<syntaxhighlight lang="euler">
begin new doors; new i; label doorLoop; label outDoors;
doors &lt;- '''list''' 100;
doors <- list 100;
i &lt;- 0;
doorLoop: '''if''' [ i &lt;- i + 1 ] &lt;= '''length''' doors '''then''' '''begin'''
i <- 0;
'''new''' j; '''label''' flipLoop;
doorLoop: if [ i <- i + 1 ] <= length doors then begin
new j; label flipLoop;
j &lt;- 0;
flipLoop: '''if''' [ j &lt;- J + i ] &lt;= '''length''' doors '''then''' '''begin'''
j <- 0;
flipLoop: if [ j <- J + i ] <= length doors then begin
doors[ j ] &lt;- '''isu''' doors[ j ] '''or''' '''not''' doors[ j ];
doors[ j ] <- isu doors[ j ] or not doors[ j ];
'''goto''' flipLoop
goto flipLoop
'''end''' '''else''' 0;
end else 0;
'''goto''' doorLoop
goto doorLoop
'''end''' '''else''' 0;
end else 0;
i &lt;- 0;
outDoors: '''if''' [ i &lt;- i + 1 ] &lt;= '''length''' doors '''then''' '''begin'''
i <- 0;
outDoors: if [ i <- i + 1 ] <= length doors then begin
'''if''' doors[ i ] '''then''' '''out''' i '''else''' 0;
if doors[ i ] then out i else 0;
'''goto''' outDoors
goto outDoors
'''end''' '''else''' 0
'''end''' $
end else 0
end $
</syntaxhighlight>


=={{header|Euler Math Toolbox}}==
=={{header|Euler Math Toolbox}}==