Old lady swallowed a fly: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added/changed whitespace and comments, aligned some statements, changed some variable names.)
Line 1,316: Line 1,316:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX program to display the lyrics for the song: "I Know an Old Lady".*/
<lang rexx>/*REXX pgm displays song lyrics for "I Know an Old Lady who Swallowed a Fly". */
@ = 'fly spider bird cat dog goat cow horse' ; #=words(@)
sw=79 /*width of terminal screen, -1.*/
first = "I know an old lady who swallowed a" ; sw=79
I_know= "I know an old lady who swallowed a"
@ate = 'She swallowed the'; @2catch= "to catch the" ; @.=
@ate = 'She swallowed the'; @2catch= "to catch the" ; @.=
@.1 = "I don't know why she swallowed a fly,"
@.1 = "I don't know why she swallowed a fly,"
@.2 = "That wriggled and jiggled and tickled inside her."; @.2.0=1
@.2 = "That wriggled and jiggled and tickled inside her." ; @.2.0=.
@.3 = "How absurd to swallow a bird!"
@.3 = "How absurd to swallow a bird!"
@.4 = "Imagine that, to swallow a cat!"
@.4 = "Imagine that, to swallow a cat!"
@.5 = "My, what a hog, to swallow a dog!"
@.5 = "My, what a hog, to swallow a dog!"
@.6 = "Just opened her throat and swallowed a goat!"
@.6 = "Just opened her throat and swallowed a goat!"
@.7 = "I wonder how she swallowed a cow?!"
@.7 = "I wonder how she swallowed a cow?!"
@.8 = "She's dead, of course!!"
@.8 = "She's dead, of course!!"
$ = 'fly spider bird cat dog goat cow horse' ; #=words($)

do j=1 for #; animal=word(@,j); say
/* [↓] display blank line*/
do j=1 for #; fauna=word($,j); say
say center(first animal',',sw); if j\==1 then say center(@.j, sw)
say center(I_know fauna',', sw); if j\==1 then say center(@.j, sw)
if j==# then leave
do k=j to 2 by -1; km=k-1
if j==# then leave /*Last verse? We're done.*/
say center(@ate word(@,k) @2catch word(@,km)',',sw)
do k=j to 2 by -1; km=k-1
say center(@ate word($,k) @2catch word($,km)',',sw)
if @.km.0\=='' then say center(@.km, sw)
if @.km.0\=='' then say center(@.km, sw)
end /*k*/
end /*k*/ /* [↑] display the lyrics of the song.*/
say center(@.1, sw)
say center(@.1, sw)
say center("I guess she'll die.", sw)
say center("I guess she'll die.", sw)
end /*j*/
end /*j*/
/*stick a fork in it, we're done.*/</lang>
/*stick a fork in it, we're all done. */</lang>
'''output''' &nbsp; (with the lyrics being centered):
<pre>
I know an old lady who swallowed a fly,
I don't know why she swallowed a fly,
I guess she'll die.

I know an old lady who swallowed a spider,
That wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly,
I don't know why she swallowed a fly,
I guess she'll die.

I know an old lady who swallowed a bird,
How absurd to swallow a bird!
She swallowed the bird to catch the spider,
That wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly,
I don't know why she swallowed a fly,
I guess she'll die.

I know an old lady who swallowed a cat,
Imagine that, to swallow a cat!
She swallowed the cat to catch the bird,
She swallowed the bird to catch the spider,
That wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly,
I don't know why she swallowed a fly,
I guess she'll die.

I know an old lady who swallowed a dog,
My, what a hog, to swallow a dog!
She swallowed the dog to catch the cat,
She swallowed the cat to catch the bird,
She swallowed the bird to catch the spider,
That wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly,
I don't know why she swallowed a fly,
I guess she'll die.

I know an old lady who swallowed a goat,
Just opened her throat and swallowed a goat!
She swallowed the goat to catch the dog,
She swallowed the dog to catch the cat,
She swallowed the cat to catch the bird,
She swallowed the bird to catch the spider,
That wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly,
I don't know why she swallowed a fly,
I guess she'll die.

I know an old lady who swallowed a cow,
I wonder how she swallowed a cow?!
She swallowed the cow to catch the goat,
She swallowed the goat to catch the dog,
She swallowed the dog to catch the cat,
She swallowed the cat to catch the bird,
She swallowed the bird to catch the spider,
That wriggled and jiggled and tickled inside her.
She swallowed the spider to catch the fly,
I don't know why she swallowed a fly,
I guess she'll die.

I know an old lady who swallowed a horse,
She's dead, of course!!
</pre>


=={{header|Ruby}}==
=={{header|Ruby}}==