Defining simple procedures


Despite the unpredictability of their occurrence, slips of the tongue are often understandable as systematic modifications of words. A Warden of New College, Oxford (1903-1924) made a name for himself (and for one particular type of lapse) by 'accidentally' transposing the first elements of words in phrases. The dear old queen would become by pure chance The queer old dean and a student might be called over the holes because he had hissed his mystery lesson and tasted the whole worm. The Warden was called Spooner and such trans-word transpositions are known as spoonerisms.

Spoonerisms are really transpositions of sounds rather than letters and in the examples the spelling was remodelled to cope with the fact. You will have noticed that istory was respelled ystery when m replaced the word's original initial h. You will notice also that it is not just any kind of word which seems to be affected by these displacements; nor is it necessarily truly adjacent words which trigger the lapse.

A spooner procedure

For the moment, however, forget these niceties and attempt to define a procedure spooner :word1 :word2 so that spooner "lame "toad will output the list [tame load] (and choose any other word pairs carefully so that the spelling works out correctly). The body of definition can be handled in one single line with just one instruction beginning with the command op and using the operations word, list, first and butfirst.

Afterwards, or perhaps before if it helps, draw an instruction diagram to show how spooner works.

If you get really stuck, click here for a clue (or two).

A modified version of spooner

When everything is running well, you might like to try changing the definition of spooner so that, instead of two separate words, it takes a single list of two words, e.g. [tame load], as input.

A variant of this (from the programmer's point of view but not the user's) is to define a new, higher-level procedure which also takes a two word list as input but then calls up your original version of spooner, separating the two words in order to provide the necessary two inputs.

Secret languages

Genuine slips of the tongue - real mistakes - often follow the spooner pattern, though it is more than likely that Spooner himself had his tongue in his cheek and his eye on the outcome. For quite overtly deliberate distortions we need to turn to secret languages. Many secret languages and indeed many more innocent word games are based on reconstructing word forms in accordance with quite simple rules, adding, deleting and moving sounds or letters. For that reason you can usefully treat them as source of ideas for LOGO procedures. It is true that to translate a whole text into a secret language will require not merely the conversion of words but also the conversion of sentences, but even if, right now, you restrict your attention to words alone, the procedures you develop can be thought of a tools for future use in some more complete translation environment. You will simply be programming bottom up.

Pig Latin and a pig of a procedure

Make a start by trying to write a procedure pig which takes one input (called :word) and outputs the input word in its Pig Latin form. What does this mean? Well, in Pig Latin, the initial consonants of words are moved to the end where they are supported by the addition of a vowel or diphthong (to make an extra syllable). A LOGO system, for example, becomes an OGOLAY ystemsay. Again there are some complications which you can temporarily ignore by just using words which begin with a single written consonant.

A pig dialect

You could also experiment with a Pig Latin dialect in which final consonants are moved to the front and followed by supporting vowels, so that Pig Latin becomes Gipi Nalati. Making the support vowel copy the following vowel is not easy given the slim resources at your disposal. Why not suppose, however, that the vowels are simply chosen at random from a list called - with little imagination but valuable transparency - "vowels. For this you will need pickrandom, below.


Define pickrandom (copy the procedure from here if you can't remember it), then test it with various inputs. Next, in order to make sure that you know how its component expressions work, take the body of the definition to pieces and experiment separately with the procedures it uses, i.e. item, random, count and their inputs. If you try repeat 50 [pr random 5], for example, it should become reasonably clear why we need to add 1 to the output of random in order to make pickrandom work correctly.

When you are happy with pickrandom use it to create a new procedure toss.up which randomly outputs heads or tails, and another throw.dice (assuming a pair of dice) which outputs anything from 2 to 12.

Work out the structure of an expression - using pickrandom - which will output a list of two elements, the first being any letter of the alphabet from A through J, the second any number between 1 and 10. Such lists could obviously identify cells in a 10 X 10 grid - remember Battleships?. Use your expression to define a procedure get.cell which outputs randomly a cell position from this virtual grid.

Ron Brasington
Department of Linguistic Science
The University of Reading