14 lines
398 B
Plaintext
14 lines
398 B
Plaintext
map: procedure options (main); /* 24/11/2011 */
|
|
declare (a1, a2, b1, b2) float;
|
|
declare d fixed decimal (3,1);
|
|
|
|
do d = 0 to 10 by 0.9, 10;
|
|
put skip edit ( d, ' maps to ', map(0, 10, -1, 0, d) ) (f(5,1), a, f(10,6));
|
|
end;
|
|
|
|
map: procedure (a1, a2, b1, b2, s) returns (float);
|
|
declare (a1, a2, b1, b2, s) float;
|
|
return (b1 + (s - a1)*(b2 - b1) / (a2 - a1) );
|
|
end map;
|
|
end map;
|