Old lady swallowed a fly: Difference between revisions

Content added Content deleted
(→‎{{header|TXR}}: Compressed pieces of text a bit using abbreviations expanded by a filter.)
Line 658: Line 658:
"that fly" not "the fly". So we do a lookup on the fly also to substitute the appropriate line, and in the fly case we skip the original line (see the first <code>@(maybe)</code>).
"that fly" not "the fly". So we do a lookup on the fly also to substitute the appropriate line, and in the fly case we skip the original line (see the first <code>@(maybe)</code>).


<lang txr>@(bind lastverse
<lang txr>@(deffilter abbr
("I know an old lady who swallowed a cow"
("IK" "I know an old lady who swallowed a") ("SW" "She swallowed the")
("SS" "she swallowed") ("CA" "to catch the") ("XX" "Perhaps she'll die")
"I don't know how she swallowed the cow"
("C" "cow") ("G" "goat") ("D" "dog") ("T" "cat") ("B" "bird")
"She swallowed the cow to catch the goat"
("S" "spider") ("F" "fly"))
"She swallowed the goat to catch the dog"
@(bind lastverse
"She swallowed the dog to catch the cat"
("IK C"
"She swallowed the cat to catch the bird"
"She swallowed the bird to catch the spider"
"I don't know how SS the C"
"SW C CA G"
"She swallowed the spider to catch the fly"
"SW G CA D"
"But I don't know why she swallowed that fly"
"Perhaps she'll die"
"SW D CA T"
"SW T CA B"
"SW B CA S"
"SW S CA F"
"But I don't know why SS F"
"XX"
""
""
"I know an old lady who swallowed a horse"
"IK horse"
"She's alive and well of course!"))
"She's alive and well of course!"))
@(bind animal_line
@(bind animal_line
("goat: Opened her throat and down went the goat!"
("G: Opened her throat and down went the G!"
"dog: What a hog to swallow a dog!"
"D: What a hog to swallow a D!"
"cat: Imagine that! She swallowed a cat!"
"T: Imagine that! She swallowed a T!"
"bird: How absurd to swallow a bird!"
"B: How absurd to swallow a B!"
"spider: That wriggled and jiggled and tickled inside her"
"S: That wriggled and jiggled and tickled inside her"
"fly: But I don't know why she swallowed the fly"))
"F: But I don't know why SS the F"))
@(define expand_backwards (song lengthened_song done))
@(define expand_backwards (song lengthened_song done))
@ (local line2 line3 verse rest animal previous_animal previous_animal_verse)
@ (local line2 line3 verse rest animal previous_animal previous_animal_verse)
@ (next :list song)
@ (next :list song)
@ (cases)
@ (cases)
IK @animal
I know an old lady who swallowed a @animal
@line2
@line2
She swallowed the @animal to catch the @previous_animal
SW @animal CA @previous_animal
@ (maybe)
@ (maybe)
But I don't@(skip)fly
But @(skip)F
@ (end)
@ (end)
@ (collect)
@ (collect)
Line 701: Line 706:
@previous_animal: @previous_animal_verse
@previous_animal: @previous_animal_verse
@ (output :into lengthened_song)
@ (output :into lengthened_song)
I know an old lady who swallowed a @previous_animal
IK @previous_animal
@previous_animal_verse
@previous_animal_verse
@ (repeat)
@ (repeat)
Line 713: Line 718:
@ (bind done nil)
@ (bind done nil)
@ (or)
@ (or)
I know an old lady @(skip)
IK @(skip)
@line2
@line2
XX
Perhaps she'll die
@ (bind lengthened_song song)
@ (bind lengthened_song song)
@ (bind done t)
@ (bind done t)
Line 731: Line 736:
@(end)
@(end)
@(expand_song lastverse song)
@(expand_song lastverse song)
@(output)
@(output :filter abbr)
@ (repeat)
@ (repeat)
@song
@song