Thue-Morse: Difference between revisions

(Add Refal)
 
(9 intermediate revisions by 7 users not shown)
Line 487:
{{out}}
<pre>0110100110010110100101100110100110010110011010010110100110010110100101100110100101101001100101100110100110010110100101100110100110010110011010010110100110010110011010011001011010010110011010010110100110010110100101100110100110010110011010010110100110010110</pre>
 
=={{header|Binary Lambda Calculus}}==
 
The (infinite) Thue-Morse sequence is output by the 115 bit BLC program
 
<pre>0001000110100001010100011010000000000101101110000101100000010111111101011001111001111110111110000011001011010000010</pre>
 
as documented in https://github.com/tromp/AIT/blob/master/characteristic_sequences/thue-morse.lam
 
Output:
 
<pre>01101001100101101001011001101001100101100110100101101001100101101001011001101001011010011001011001101001100101101001011001101001100101100110100101101001100101100110100110010110100101100110100101101001...</pre>
 
=={{header|BQN}}==
Line 882 ⟶ 894:
{{out}}
<pre>0110100110010110100101100110100110010110011010010110100110010110</pre>
 
=={{header|EasyLang}}==
{{trans|BASIC256}}
<syntaxhighlight>
func$ tmorse s$ .
for i to len s$
if substr s$ i 1 = "1"
k$ &= "0"
else
k$ &= "1"
.
.
return s$ & k$
.
tm$ = "0"
print tm$
for j to 7
tm$ = tmorse tm$
print tm$
.
</syntaxhighlight>
 
=={{header|Elena}}==
Line 1,147 ⟶ 1,180:
| 0110100110010110100101100110100110010110011010010110100110010110
|}
 
=={{header|F_Sharp|F#}}==
<syntaxhighlight lang="fsharp">
// Thue-Morse. Nigel Galloway: April 16th., 2024
let rec fG n g=match n with 0->g |1->g+1 |n ->fG(n/2)(g+n&&&1)
let thueMorse=Seq.initInfinite(fun n->(fG n 0)%2)
thueMorse|>Seq.take 25|>Seq.iter(printf "%d "); printfn ""
</syntaxhighlight>
{{out}}
<pre>
0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 0
</pre>
 
=={{header|Factor}}==
Line 1,280 ⟶ 1,325:
{{FormulaeEntry|page=https://formulae.org/?script=examples/Thue-Morse}}
 
'''=== Solution 1''' ===
 
[[File:Fōrmulæ - Thue–Morse sequence 01.png]]
Line 1,286 ⟶ 1,331:
[[File:Fōrmulæ - Thue–Morse sequence 11.png]]
 
'''=== Solution 2''' ===
 
[[File:Fōrmulæ - Thue–Morse sequence 02.png]]
Line 1,292 ⟶ 1,337:
[[File:Fōrmulæ - Thue–Morse sequence 11.png]]
 
'''=== Solution 3''' ===
 
[[File:Fōrmulæ - Thue–Morse sequence 03.png]]
Line 1,298 ⟶ 1,343:
[[File:Fōrmulæ - Thue–Morse sequence 11.png]]
 
'''=== Solution 4''' ===
 
Notice that this solution generates a string.
Line 1,306 ⟶ 1,351:
[[File:Fōrmulæ - Thue–Morse sequence 12.png]]
 
'''=== Solution 5''' ===
 
Notice that this solution generates a string.
Line 1,314 ⟶ 1,359:
[[File:Fōrmulæ - Thue–Morse sequence 12.png]]
 
'''=== Solution 6''' ===
 
Notice that this solution generates a string.
 
[[File:Fōrmulæ - Thue–Morse sequence 06.png]]
 
[[File:Fōrmulæ - Thue–Morse sequence 12.png]]
 
=== Solution 7. L-system ===
 
There are generic functions written in Fōrmulæ to compute an L-system in the page [[L-system#Fōrmulæ | L-system]].
 
The program that creates a Hilbert curve is:
 
[[File:Fōrmulæ - L-system - Thue-Morse 01.png]]
 
[[File:Fōrmulæ - Thue–Morse sequence 12.png]]
Line 2,455 ⟶ 2,510:
^C</pre>
 
=={{header|REFALRefal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
= <Prout <ThueMorse 7>>
Line 2,786 ⟶ 2,841:
=={{header|Wren}}==
{{trans|Kotlin}}
<syntaxhighlight lang="ecmascriptwren">var thueMorse = Fn.new { |n|
var sb0 = "0"
var sb1 = "1"
2,171

edits