         Edinburgh IMP77 Compiler - Version 8.4

    1  %begin
    2    !%external %real %fn %spec sqrt %alias "sqrt" (%real n)  {should be in prims. Using Linux/C's external here.}
    3    
    4    %routine TPK(%real %array %name a, b)
    5      ! given 11 input values a(0),...,a(10), this routine
    6      ! produces 22 output values b(0),...b(21), according
    7      ! to the classical TPK algorithm
    8      %real %fn f(%real t)
    9        %result = sqrt(|t|) + 5 * t^3
   10      %end
   11      %real y
   12      %integer i
   13      %cycle i = 10, -1, 0
   14        y = f(a(i))
   15        y = 999 %if y > 400
   16        b(20-2*i) = i
   17        b(21-2*i) = y
   18      %repeat
   19    %end; ! TPK
   20  
   21    %real %array a(0:10), b(0:21)
   22  
   23    TPK(a,b)
   24  
   25  %endofprogram

   17 Statements compiled
