Old lady swallowed a fly: Difference between revisions
m
no edit summary
No edit summary |
mNo edit summary |
||
Line 1,805:
=={{header|FutureBasic}}==
An added feature of this code is the addition of a proper English voice reciting the rhyme back to you. This is compilable as a standalone app on M1, M2 or Intel Macs.
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
begin enum output
void local fn OldLadySwallowedAFly▼
_firstAnimal = 0
NSUInteger i, j, count▼
_lastAnimal = 7
end enum
CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
NSLogClear
CFArrayRef animals = @[@"fly", @"spider", @"bird", @"cat", @"dog", @"goat", @"cow", @"horse.."]
CFArrayRef verses = @[@"",¬
@"I don't know why she swallowed the fly
@"That wriggled and jiggled and tickled inside her.",¬
@"How absurd, to swallow a bird!",¬
Line 1,820 ⟶ 1,829:
@"She just opened her throat and swallowed that goat!",¬
@"I wonder how she swallowed a cow?",¬
@"She's dead, of course!"]
for i = 0 to
NSLog( @"There was an old lady who swallowed a %@.", animals[i] ) : MutableStringAppendFormat( mutStr, @"There was an old lady who swallowed a %@.\n", animals[i] )
if i ==
if i >
if i ==
if ( i > 0 )
for j = i to 1 step -1
CFStringRef p
NSLog( @"\tShe swallowed the %@ to catch the %@.", animals[j], animals[j-1] )▼
if fn StringIsEqual( animals[j
▲ NSLog( @"\tShe swallowed the %@ to catch the %@
if j == 2 then NSLog(@"\tThat wriggled and jiggled and tickled inside her.") : MutableStringAppendString( mutStr, @"\tThat wriggled and jiggled and tickled inside her.\n" )
if j == 1 then NSLog( @"%@", verses[1] ) : MutableStringAppendFormat( mutStr, @"%@\n", verses[1] ) : break
next
end if
next
SpeechSynthesizerRef ref = fn SpeechSynthesizerWithVoice( @"com.apple.speech.synthesis.voice.daniel.premium" )
fn SpeechSynthesizerStartSpeakingString( ref, mutStr )
end fn
Line 1,842 ⟶ 1,856:
HandleEvents
</syntaxhighlight>
The following is both printed and recited back as audio in a proper English male voice.
{{out}}
<pre>
There was an old lady who swallowed a fly.
I don't know why she swallowed the fly
There was 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 the fly
There was 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 the fly
There was an old lady who swallowed a cat.
Imagine that, she swallowed 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 the fly
There was an old lady who swallowed a dog.
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 the fly
There was an old lady who swallowed a goat.
She just opened her throat and swallowed that 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 the fly
There was 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 the fly
There was an old lady who swallowed a horse...
She's dead, of course!
</pre>
|