Thue-Morse: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
<lang AWK>BEGIN{print x="0"} |
<lang AWK>BEGIN{print x="0"} |
||
{gsub(/./," &",x);gsub(/ 0/,"01",x);gsub(/ 1/,"10",x);print x}</lang> |
{gsub(/./," &",x);gsub(/ 0/,"01",x);gsub(/ 1/,"10",x);print x}</lang> |
||
=={{header|C++}}== |
|||
<lang cpp> |
|||
#include <iostream> |
|||
#include <iterator> |
|||
#include <vector> |
|||
int main( int argc, char* argv[] ) { |
|||
std::vector<bool> t; |
|||
t.push_back( 0 ); |
|||
size_t len = 1; |
|||
while( len < 80 ) { |
|||
std::copy( t.begin(), t.end(), std::ostream_iterator<bool>( std::cout, "" ) ); |
|||
std::cout << "\n"; |
|||
for( size_t x = 0; x < len; x++ ) |
|||
t.push_back( t[x] ? 0 : 1 ); |
|||
len = t.size(); |
|||
} |
|||
return 0; |
|||
} |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
0 |
|||
01 |
|||
0110 |
|||
01101001 |
|||
0110100110010110 |
|||
01101001100101101001011001101001 |
|||
0110100110010110100101100110100110010110011010010110100110010110 |
|||
</pre> |
|||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |