Loops/While: Difference between revisions
Merge duplicated example for Lambdatalk
(Add lang example) |
(Merge duplicated example for Lambdatalk) |
||
Line 1,928:
</syntaxhighlight>
Alternative solution:
=={{header|Lang}}==▼
<syntaxhighlight lang="lang">▼
$n = 1024▼
while($n > 0) {▼
fn.println($n)▼
$n //= 2▼
}▼
</syntaxhighlight>▼
=={{header|Lang5}}==▼
{{trans|Factor}}▼
<syntaxhighlight lang="lang5">: /i / int ; : 0= 0 == ;▼
: dip swap '_ set execute _ ; : dupd 'dup dip ;▼
: 2dip swap '_x set swap '_y set execute _y _x ;▼
: while▼
do dupd 'execute 2dip▼
rot 0= if break else dup 2dip then▼
loop ;▼
1024 "dup 0 >" "dup . 2 /i" while</syntaxhighlight>▼
<syntaxhighlight lang="scheme">
{def while
Line 1,972 ⟶ 1,950:
1
</syntaxhighlight>
▲=={{header|Lang}}==
▲<syntaxhighlight lang="lang">
▲$n = 1024
▲while($n > 0) {
▲ fn.println($n)
▲ $n //= 2
▲}
▲</syntaxhighlight>
▲=={{header|Lang5}}==
▲{{trans|Factor}}
▲<syntaxhighlight lang="lang5">: /i / int ; : 0= 0 == ;
▲: dip swap '_ set execute _ ; : dupd 'dup dip ;
▲: 2dip swap '_x set swap '_y set execute _y _x ;
▲: while
▲ do dupd 'execute 2dip
▲ rot 0= if break else dup 2dip then
▲ loop ;
▲1024 "dup 0 >" "dup . 2 /i" while</syntaxhighlight>
=={{header|langur}}==
|