Set right-adjacent bits: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: fixed off-by-one error) |
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: added an example as per task spec) |
||
Line 623: | Line 623: | ||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
{{incomplete|Raku|Missing the examples asked for}} |
|||
A left-to-right ordered collection of bits is more commonly referred to as an Integer in Raku. |
A left-to-right ordered collection of bits is more commonly referred to as an Integer in Raku. |
||
Line 638: | Line 637: | ||
} |
} |
||
say "Powers of 2 ≤ 8, 0 - Right-adjacent-bits: 2"; |
|||
⚫ | |||
.&rab(2).base(2).fmt('%04s').say for <8 4 2 1 0>; |
|||
⚫ | |||
for 8,4, 18455760086304825618,5, 5444684034376312377319904082902529876242,15 -> $integer, $bits { |
for 8,4, 18455760086304825618,5, 5444684034376312377319904082902529876242,15 -> $integer, $bits { |
||
Line 652: | Line 653: | ||
}</lang> |
}</lang> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre>Powers of 2 ≤ 8, 0 - Right-adjacent-bits: 2 |
||
1110 |
|||
0111 |
|||
0011 |
|||
0001 |
|||
0000 |
|||
Integer: 8 - Right-adjacent-bits: up to 4 |
|||
1000 |
1000 |
||
1100 |
1100 |