(* Chapter 3: file README03.p *) Pascal code for Chapter 3 of Programming Languages: Concepts and Constructs, by Ravi Sethi, Addison Wesley, 1996 The files are uniq.p table.p ------------------------------------------------------------------- FILE: uniq.p PROGRAM: uniq PURPOSE: illustrates informal use of invariants for program design SEE: Section 3.1, pages 62-63; FIgure 3.4, page 68 COMMENT: The program removes adjacent duplicates. The evolution of imperative languages from assembly language to Pascal is illustrated by a sequence of programs for removing adjacent duplicates from a list of elements. The first such is a RAM program in Chapter 1 (see file README01.p and the code for Chapter 1). Chapter 4 (see README04.p) contains a program that allows list elements to be bibliographic entries. All operations on such lists have to be programmed explicitly using procedures. With the input 1 1 2 2 2 3 1 4 4 0 program uniq produces the output 1 2 3 1 4 ------------------------------------------------------------------- FILE: table.p PROGRAM: table PURPOSE: Uses the linear search fragment developed in Section 3.5 SEE: pages 82-86 COMMENT: The program reads a list of integers and writes out an integer if is seen for the first time. Thus, it removes duplicates, not just adjacent duplicates. The program fragment for linear search developed in Section 3.5 forms the body of function find in program table, a program created simply to test the code for linear search. Program table reads a list of integers and writes out an integer if it has not already appeared in the list. With input 1 1 2 2 2 3 1 4 4 0 program table produces the output 1 2 3 4 -------------------------------------------------------------------