Anonymous user
Thue-Morse: Difference between revisions
m
→{{header|REXX}}: added a programming note to the REXX section header (defines weight and pop count).
m (→{{header|REXX}}: added a programming note to the REXX section header (defines weight and pop count).) |
|||
Line 147:
=={{header|REXX}}==
===using functions===
Programming note: ''pop count'' (or ''weight'') is the number of <b>1</b>'s bits in the binary representation of a number.
<lang rexx>/*REXX program generates & displays the Thue─Morse sequence up to the Nth item*/
parse arg N . /*obtain the optional argument from CL.*/
Line 159 ⟶ 160:
$pop: return length(space(translate(arg(1),,0),0)) /*count 1's in number.*/
$weight: return $pop(x2b(d2x(arg(1)))) /*dec──►bin, pop count*/</lang>
'''output''' when using the default input:
<pre>
01101001100101101001011001101001100101100110100101101001100101101001011001101001
|