Old lady swallowed a fly: Difference between revisions
Content added Content deleted
Line 1: | Line 1: | ||
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.{{draft task}} |
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.{{draft task}} |
||
=={{header|ALGOL 68}}== |
|||
{{works with|ALGOL 68|Revision 1 - no extensions to language used.}} |
|||
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny].}} |
|||
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to extensive use of '''format'''[ted] ''transput''.}} |
|||
<lang algol68>#!/usr/local/bin/a68g --script # |
|||
STRING |
|||
sw="swallow",swd=sw+"ed", |
|||
ikn="I know an old lady who "+swd+" a ", |
|||
tsa=". To "+sw+" a ", |
|||
sst="She "+swd+" the ",tct=" to catch the ", |
|||
dky="I don't know why she "+swd+" the fly.", |
|||
die="Perhaps she'll die."; |
|||
INT count pr := 0; [9]STRING pr; |
|||
PROC vs = (STRING wot,[]STRING co)VOID: ( |
|||
printf(($g$,ikn,wot,".",$l$)); |
|||
IF UPB co = 1 THEN |
|||
printf(($gl$,co)) |
|||
ELIF UPB co > 1 THEN |
|||
printf(($g$,co,wot+".",$l$)) |
|||
FI; |
|||
IF count pr NE UPB pr THEN |
|||
pr[count pr+:=1]:=wot; |
|||
FOR i FROM count pr BY -1 TO 2 DO |
|||
printf(($gl$,sst+pr[i]+tct+pr[i-1]+".")) |
|||
OD; |
|||
printf(($glg2l$,dky,die)) |
|||
FI |
|||
); |
|||
vs("fly",()); |
|||
vs("spider","That wriggled and jiggled and tickled inside her."); |
|||
vs("Bird",("Quite absurd",tsa)); |
|||
vs("Cat",("Fancy that",tsa)); |
|||
vs("Dog",("What a hog",tsa)); |
|||
vs("Pig",("Her mouth was so big",tsa)); |
|||
vs("Goat",("She just opened her throat",tsa)); |
|||
vs("Cow",("I don't know how",tsa)); |
|||
vs("Donkey",("It was rather wonky",tsa)); |
|||
vs("Horse","She's dead, of course!")</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |
||
Boring, ad hoc dictionary based decompression. The encoder was arguably more interesting, though. Output is different from listing in talk page in punctuations and capitalizations. |
Boring, ad hoc dictionary based decompression. The encoder was arguably more interesting, though. Output is different from listing in talk page in punctuations and capitalizations. |