Thue-Morse: Difference between revisions

→‎{{header|REXX}}: added a 3rd REXX version.
m (→‎{{header|REXX}}: added a programming note to the REXX section header (defines weight and pop count).)
(→‎{{header|REXX}}: added a 3rd REXX version.)
Line 174:
end /*j*/
say $ /*stick a fork in it, we're all done. */</lang>
'''output''' &nbsp; is identical to the 1<sup>st</sup> REXX version. <br><br>
 
===using 2's complement===
Programming note: &nbsp; this method displays the sequence, but it doubles in (binary) length each iteration.
 
Because of this, the displaying of the output lacks the granularity of the first two REXX versions.
<lang rexx>/*REXX program generates & displays the Thue─Morse sequence up to the Nth item*/
parse arg N . /*obtain the optional argument from CL.*/
if N=='' | N=="," then N=6 /*Not specified? Then use the default.*/
$=0 /*the Thue─Morse sequence (so far). */
do j=1 for N /*generate sequence up to the Nth item.*/
$=$ || translate($, 10, 01) /*append $'s complement to $. */
end /*j*/
say $ /*stick a fork in it, we're all done. */</lang>
'''output''' &nbsp; when using the default input:
<pre>
0110100110010110100101100110100110010110011010010110100110010110
</pre>
 
=={{header|SQL}}==