Loops/Continue: Difference between revisions
Content added Content deleted
No edit summary |
(→{{header|Prolog}}: Adding Prolog) |
||
Line 1,844: | Line 1,844: | ||
Write-Host -NoNewline ", " |
Write-Host -NoNewline ", " |
||
}</lang> |
}</lang> |
||
=={{header|Prolog}}== |
|||
Prolog doesn't have a continue statement. So I just use a conditional that ends the body of the predicate. |
|||
{{works with|GNU Prolog}} |
|||
{{works with|SWI Prolog}} |
|||
<lang Prolog> |
|||
:- initialization(main). |
|||
print_list(Min, Max) :- |
|||
Min < Max, |
|||
write(Min), |
|||
Min1 is Min + 1, |
|||
( |
|||
Min =:= Max div 2 |
|||
-> nl |
|||
; write(',') |
|||
), |
|||
print_list(Min1, Max). |
|||
print_list(Max, Max) :- |
|||
write(Max), |
|||
nl. |
|||
main :- |
|||
print_list(1, 10). |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
1,2,3,4,5 |
|||
6,7,8,9,10 |
|||
</pre> |
|||
=={{header|Python}}== |
=={{header|Python}}== |