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. |
|||
⚫ | |||
while $n = $n div 2 { |
|||
say $n; |
|||
}</lang> |
|||
⚫ | |||
<code>until ''condition''</code> is equivalent to <code>while not ''condition''</code>. |
|||
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}}== |