RosettaCodeData/Task/Map-range/Asymptote/map-range.asymptote
2026-04-30 12:34:36 -04:00

8 lines
235 B
Text

real mapRange(int s, int a1, int a2, int b1, int b2) {
return b1 + (s - a1) * (b2 - b1) / (a2 - a1);
}
for (int i = 0; i <= 10; ++i) {
real r = mapRange(i, 0, 10, -1, 0);
write( (string)i + " maps to " + format("%0.1f", r) );
}