CSC 8310 Linguistics of Programming Languages
Dr. David Matuszek,
Fall 1998, Villanova University
Your assignment is to write an ML program to translate an English
sentence into "Pig Latin."
Pig Latin is a spoken "secret code" commonly used by American
schoolchildren. Pig Latin is very simple but can be difficult to
understand when spoken fast. The rules are:
- If a word begins with a vowel, add "hay" to the end
of the word. For example, "apple" becomes
"applehay." (Some dialects use "yay"
rather than "hay;" if you would rather program it this way, that's
OK with me.)
- If a word begins with one or more consonants, move those
initial consonants to the end of the word and add "ay."
For example, "strength" becomes
when the cats away the mice will play
enwhay ethay atscay awayhay ethay icemay illway ayplay
- You don't need to read in sentences; you can define them in
- Don't worry about capital letters; everything can be
- Don't use any punctuation.
- Use single spaces to separate words.
- Always treat "y" as a consonant.
- ML is interactive; play with it. Get used to it a little
before you try to do any serious work. This will help a lot when
you try to actually start using it.
- You have lots of resources available on line; do some reading,
and try out some of the examples. You should be able to have ML
and Netscape (or IE) open at the same time, so you can try things
out as you read about them.
- ML doesn't give very good error messages, and it's often hard
to tell what it's complaining about. So write little functions,
one at a time, and test each one out before writing the next
- If you can't keep your functions small, at least build them up
and test them a line or two at a time. Otherwise you'll have a big
function with an error in it somewhere that you just can't
- A (paper) listing of your program.
- A (paper) transcript of a sample run of your program, showing
how it converts a few sentences into Pig Latin.