How to resolve the algorithm Old lady swallowed a fly step by step in the Maple programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Old lady swallowed a fly step by step in the Maple programming language

Table of Contents

Problem Statement

Present a program which emits the lyrics to the song   I Knew an Old Lady Who Swallowed a Fly,   taking advantage of the repetitive structure of the song's lyrics. This song has multiple versions with slightly different lyrics, so all these programs might not emit identical output.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Old lady swallowed a fly step by step in the Maple programming language

Source code in the maple programming language

swallowed := ["fly", "spider", "bird", "cat", "dog", "cow", "horse"]:
phrases := ["I don't know why she swallowed a fly, perhaps she'll die!",
		  "That wriggled and wiggled and tiggled inside her.",
		  "How absurd to swallow a bird.",
		  "Fancy that to swallow a cat!",
		  "What a hog, to swallow a dog.",
		  "I don't know how she swallowed a cow.",
		  "She's dead, of course."]:
for i to numelems(swallowed) do
	printf("There was an old lady who swallowed a %s.\n%s\n", swallowed[i], phrases[i]);
	if i > 1 and i < 7 then
		for j from i by -1 to 2 do
			printf("\tShe swallowed the %s to catch the %s.\n", swallowed[j], swallowed[j-1]);
		end do;
		printf("%s\n\n", phrases[1]);
	elif i = 1 then
		printf("\n");
	end if;
end do;

  

You may also check:How to resolve the algorithm Distributed programming step by step in the Tcl programming language
You may also check:How to resolve the algorithm Element-wise operations step by step in the Rust programming language
You may also check:How to resolve the algorithm Vector step by step in the Nanoquery programming language
You may also check:How to resolve the algorithm Longest increasing subsequence step by step in the Python programming language
You may also check:How to resolve the algorithm Home primes step by step in the Mathematica/Wolfram Language programming language