Thue-Morse: Difference between revisions

Content added Content deleted
(Added PowerShell)
(→‎{{header|Algol 68}}: Added Algl 68)
Line 1:
{{draft task}}Make [http://en.wikipedia.org/wiki/Thue%E2%80%93Morse_sequence Thue-Morse sequence].
 
 
=={{header|ALGOL 68}}==
<lang algol68># "flips" the "bits" in a string (assumed to contain only "0" and "1" characters) #
OP FLIP = ( STRING s )STRING:
BEGIN
STRING result := s;
FOR char pos FROM LWB result TO UPB result DO
result[ char pos ] := IF result[ char pos ] = "0" THEN "1" ELSE "0" FI
OD;
result
END; # FLIP #
 
# print the first few members of the Thue-Morse sequence #
STRING tm := "0";
TO 7 DO
print( ( tm, newline ) );
tm +:= FLIP tm
OD</lang>
{{out}}
<pre>
0
01
0110
01101001
0110100110010110
01101001100101101001011001101001
0110100110010110100101100110100110010110011010010110100110010110
</pre>
 
=={{header|AWK}}==