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"> |
|||
doors <- '''list''' 100; |
|||
i <- 0; |
|||
⚫ | |||
i <- 0; |
|||
'''new''' j; '''label''' flipLoop; |
|||
⚫ | |||
j <- 0; |
|||
flipLoop: '''if''' [ j <- J + i ] <= '''length''' doors '''then''' '''begin''' |
|||
j <- 0; |
|||
doors[ j ] <- '''isu''' doors[ j ] '''or''' '''not''' doors[ j ]; |
|||
'''goto''' flipLoop |
|||
'''end''' '''else''' 0; |
|||
'''goto''' doorLoop |
|||
'''end''' '''else''' 0; |
|||
i <- 0; |
|||
outDoors: '''if''' [ i <- i + 1 ] <= '''length''' doors '''then''' '''begin''' |
|||
i <- 0; |
|||
'''if''' doors[ i ] '''then''' '''out''' i '''else''' 0; |
|||
'''goto''' outDoors |
|||
'''end''' '''else''' 0 |
|||
⚫ | |||
end else 0 |
|||
⚫ | |||
</syntaxhighlight> |
|||
=={{header|Euler Math Toolbox}}== |
=={{header|Euler Math Toolbox}}== |