Thue-Morse: Difference between revisions
Content added Content deleted
(→{{header|Fōrmulæ}}: Added L-system solution) |
(Realize in F#) |
||
Line 1,181: | Line 1,181: | ||
|} |
|} |
||
=={{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 when n%2=0->fG (n/2) g |n->fG(n/2)(g+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}}== |
=={{header|Factor}}== |
||
{{works with|Factor|0.98}} |
{{works with|Factor|0.98}} |