program difint(input,output); (* differences between integers. tom schneider *) const (* begin module version *) version = 1.05; (* of difint.p 1996 October 24 origin 1986 dec 2 *) (* end module version *) (* begin module describe.difint *) (* name difint: differences between integers synopsis difint(input: in, output: out); files input: a set of integers, one per line. Lines that begin with "*" are ignored. output: the difference between each integer and the previous one. describe Lines that begin with an asterisk ('*') are first copied to the output. then the difference between each integer in input and the previous one is given to the output. author Thomas Dana Schneider technical notes The program originally acted as if the integer before the first one is zero, but this creates artifacts. The initial data point is now dropped. However, data often comes separate into chunks. This is marked by the comments. So the program resets everytime there is a comment line. bugs none known *) (* end module describe.difint *) var current, previous: integer; (* two integers from the input file *) haveprevious: boolean; (* do we have the previous value? *) begin haveprevious := false; while not eof(input) do begin if input^='*' then begin (* copy lines beginning with '*' to output *) while not eoln(input) do begin write(output,input^); get(input); end; haveprevious := false; readln(input); writeln(output) end else begin readln(input, current); if haveprevious then writeln(output,current-previous:10); haveprevious := true; previous := current; end; end end.