Loops/While: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 442: Line 442:


=={{header|Perl 6}}==
=={{header|Perl 6}}==
{{works with|Rakudo|#21 "Seattle"}}


Note that <tt>+></tt> is the Perl 6 right bit-shift operator, it is equivalent to dividing by two. The <tt>+</tt> indicates that it is a numeric operation, and the <tt>></tt> indicates that it is the right bit-shift operation since the tag is pointing to the right.
<lang perl6>my Int $n = 2 * 1024;
while $n = $n div 2 {
say $n;
}</lang>


<lang perl6>my $n = 1024*2;
<code>until ''condition''</code> is equivalent to <code>while not ''condition''</code>.


<lang perl6>my Int $n = 2 * 1024;
say $n while ($n +>= 1) != 0;</lang>

until ($n = $n div 2) <= 0 {
Here is a solution without the restraints:
say $n;

}</lang>
<lang perl6>say 1024 +> $_ for 0..10;</lang>


=={{header|PHP}}==
=={{header|PHP}}==