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: &nbsp; ''pop count'' &nbsp; (or &nbsp; ''weight'') &nbsp; is the number of &nbsp; <b>1</b>'s &nbsp; 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''' &nbsp; when using the default input:
<pre>
01101001100101101001011001101001100101100110100101101001100101101001011001101001