Old lady swallowed a fly: Difference between revisions
Content added Content deleted
Line 2: | Line 2: | ||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
===Using Logic=== |
|||
{{works with|ALGOL 68|Revision 1 - no extensions to language used.}} |
{{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].}} |
{{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].}} |
||
Line 43: | Line 44: | ||
vs("Donkey",("It was rather wonky",tsa)); |
vs("Donkey",("It was rather wonky",tsa)); |
||
vs("Horse","She's dead, of course!")</lang> |
vs("Horse","She's dead, of course!")</lang> |
||
===Using a dictionary=== |
|||
=={{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 |
|||
a="UAVEN",e="UEVGN",g="UGVPN",p="UPVDN",d="UDVCN",c="UCVBN",b="UBVSN",s="USVXN",f="Y",z="Z",l=""; |
|||
[]STRING |
|||
w=( # Assuming ASCII ordering # |
|||
"Donkey","Bird","Cat","Dog","Cow","Fancy that","Goat","Horse", |
|||
"I know an old lady who swallowed a ","She just opened her throat", |
|||
"I don't know how",". To swallow a ","Her mouth was so big",".", |
|||
"She's dead, of course!","Pig","Quite absurd","It was rather wonky", |
|||
"spider","That wriggled and jiggled and tickled inside her.", |
|||
"She swallowed the "," to catch the ","What a hog","fly", |
|||
"I don't know why she swallowed the fly.","Perhaps she'll die."), |
|||
v=( |
|||
"IXN",f,z,l, |
|||
"ISN","T",s,f,z,l, |
|||
"IBN","QLBN",b,s,f,z,l, |
|||
"ICN","FLCN",c,b,s,f,z,l, |
|||
"IDN","WLDN",d,c,b,s,f,z,l, |
|||
"IPN","MLPN",p,d,c,b,s,f,z,l, |
|||
"IGN","JLGN",g,p,d,c,b,s,f,z,l, |
|||
"IEN","KLEN",e,g,p,d,c,b,s,f,z,l, |
|||
"IAN","RLAN",a,e,g,p,d,c,b,s,f,z,l, |
|||
"IHN","O"); |
|||
FOR i TO UPB v DO |
|||
FOR j TO UPB v[i] DO |
|||
print(w[ABS v[i][j] - ABS "A" + 1]) |
|||
OD; |
|||
print(new line) |
|||
OD</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. |