Thue-Morse: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add Draco) |
Not a robot (talk | contribs) (Add CLU) |
||
Line 668: | Line 668: | ||
0110100110010110100101100110100110010110011010010110100110010110 |
0110100110010110100101100110100110010110011010010110100110010110 |
||
</pre> |
</pre> |
||
=={{header|CLU}}== |
|||
<lang clu>% Yields an infinite Thue-Morse sequence, digit by digit |
|||
tm = iter () yields (char) |
|||
n: int := 1 |
|||
s: string := "0" |
|||
while true do |
|||
while n <= string$size(s) do |
|||
yield(s[n]) |
|||
n := n + 1 |
|||
end |
|||
s2: array[char] := array[char]$[] |
|||
for c: char in string$chars(s) do |
|||
if c='0' |
|||
then array[char]$addh(s2, '1') |
|||
else array[char]$addh(s2, '0') |
|||
end |
|||
end |
|||
s := s || string$ac2s(s2) |
|||
end |
|||
end tm |
|||
% Print the first 64 characters |
|||
start_up = proc () |
|||
AMOUNT = 64 |
|||
po: stream := stream$primary_output() |
|||
n: int := 0 |
|||
for c: char in tm() do |
|||
stream$putc(po, c) |
|||
n := n + 1 |
|||
if n = AMOUNT then break end |
|||
end |
|||
end start_up</lang> |
|||
{{out}} |
|||
<pre>0110100110010110100101100110100110010110011010010110100110010110</pre> |
|||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |