Tips for Things to do 3

Spoonerisms

Your aim is to define spooner as accepting two separate words as input. If you choose to call the inputs :word1 and :word2, then the first line of the definition is:

to spooner :word1 :word2

With the header set up in this way, you will be able to use the expressions :word1 and :word2 in the body of the procedure definition to refer generally to whatever particular words are provided when the procedure is called.

Because a procedure can only output one thing, the output of spooner will be a single list. This list is intended to contain two new words formed by re-joining various parts of the two input words.

Joining two sequences of letters (i.e words) to form a new word is the business of the primitive operation called word. For example:

word "lo "go

is an expression which outputs the word logo.

So what are the two character sequences found in :word1 and :word2 which word would need to join together to make the first word of the spoonerism (i.e. the first word of the list output by spooner)? Well if it happened that spooner's two inputs were "lame and "toad, the first word of the spoonerism would be "tame and this is made from the first letter of the second word followed by everything but the first letter of the first word. Generalising this notion in real Logo-speak is not very difficult or very different:

word first :word2 bf :word1

Now, since word first :word2 bf :word1 is an expression which outputs a word, it can be directly used to provide the first input to se which - as you should know - is the obvious candidate for packaging together the two words of the spoonerism. Clearly, the second input to se can in turn be provided by another expression headed by word though clearly with different inputs.

The list which spooner must eventually pass on to the outside world will derive, then, from an expression of this general pattern:

se <some expression which outputs the first word> <some expression which outputs the second word>

If the output of se is presented to op, op will set the alarm bells ringing, get spooner to output the list and then shut down.


Go back to Things to do 3

Ron Brasington
Department of Linguistic Science
The University of Reading
Reading
UK

E-mail: ron.brasington@rdg.ac.uk