MODULE TrigTables;

  FROM InOut     IMPORT Write, WriteLn, WriteCard, WriteString;
  FROM RealInOut IMPORT WriteReal;
  FROM ASCII     IMPORT ff;
  FROM MathLib   IMPORT sin,cos,arctan;


TYPE 
  TrigFunction = PROCEDURE(REAL):REAL;
  

PROCEDURE PrintTable(fn: ARRAY OF CHAR; f: TrigFunction;
		     lowLimit, hiLimit, stepWidth: REAL);
BEGIN
  WriteString(fn); WriteString(' tabulated from ');
  WriteReal(lowLimit,6); WriteString(' up to ');
  WriteReal(hiLimit,6); WriteString(' in steps of ');
  WriteReal(stepWidth,6); WriteLn;
  WriteString('argument                    value'); WriteLn;
  WriteString('---------------------------------'); WriteLn;
  WriteLn;
  WHILE lowLimit <= hiLimit DO
    WriteReal(lowLimit,6);
    WriteReal(f(lowLimit),18);
    WriteLn;
    IF lowLimit + stepWidth = lowLimit THEN
      WriteString('stepwidth too small');
      HALT;
    END;
    lowLimit := lowLimit + stepWidth;
  END;
END PrintTable;

BEGIN (* TrigTables *)
  PrintTable('sine', sin, 0.0,3.14159 / 2.0,0.1);
  PrintTable('cosine',cos,0.0,3.14159 / 2.0,0.1);
  PrintTable('arctangent',arctan,0.0,0.9,0.1);
END TrigTables.
