Good Things Come in Small Packages

Applying Techniques More Widely

Can the techniques we have looked at in the context of lists of integers be applied to lists of other types - strings (TEXT), say? Let us change the type of the items contained in the lists:


TYPE
  ItemType = TEXT;

Procedures, such as ListHead, will now return a TEXT item rather than an INTEGER.

Consider the following specification:

Write a procedure to return the number of characters in a list of strings.

Once again we should think about the inputs and outputs. Do we have to look at every item in the list, or just some? Do we know of any built in facilities or library facilities that will help us? The Text Interface contains a Length procedure that gives the length of an individual string - is this of use? Try to develop a solution to this problem. See how the procedures we have already developed take us a long way towards developing a solution to this particular problem, even though we are now dealing with TEXT items rather than just INTEGERs.

To
Previous Page

To Overview

To Next Page