How to resolve the algorithm Thue-Morse step by step in the Ada programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Thue-Morse step by step in the Ada programming language
Table of Contents
Problem Statement
Create a Thue-Morse sequence.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Thue-Morse step by step in the Ada programming language
Source code in the ada programming language
with Ada.Text_IO; use Ada.Text_IO;
procedure Thue_Morse is
function Replace(S: String) return String is
-- replace every "0" by "01" and every "1" by "10"
(if S'Length = 0 then ""
else (if S(S'First) = '0' then "01" else "10") &
Replace(S(S'First+1 .. S'Last)));
function Sequence (N: Natural) return String is
(if N=0 then "0" else Replace(Sequence(N-1)));
begin
for I in 0 .. 6 loop
Ada.Text_IO.Put_Line(Integer'Image(I) & ": " & Sequence(I));
end loop;
end Thue_Morse;
You may also check:How to resolve the algorithm Multisplit step by step in the Bracmat programming language
You may also check:How to resolve the algorithm Radical of an integer step by step in the Ruby programming language
You may also check:How to resolve the algorithm 24 game step by step in the J programming language
You may also check:How to resolve the algorithm Return multiple values step by step in the Z80 Assembly programming language
You may also check:How to resolve the algorithm Abundant odd numbers step by step in the PureBasic programming language