Map range: Difference between revisions

m (Formatting.)
Line 2,905:
 
=={{header|Vala}}==
<lang vala>double map_range(double[] as, double[]int ba1, doubleint sa2, int b1, int b2) {
{{trans|D}}
return b1+(s-a1)*(b2-b1)/(a2-a1);
<lang vala>double map_range(double[] a, double[] b, double s) {
}
return b[0] + ((s - a[0]) * (b[1] - b[0]) / (a[1] - a[0]));
 
void main() {
constfor double[](int r1s = {0.0,; 10.0}s < 11; s++){
print("%2d maps to %5.2f\n", s, map_range(r1s, r20, (double)s10, -1, 0));
const double[] r2 = {-1.0, 0.0};
}
for (int s = 0; s < 11; s++)
print("%2d maps to %5.2f\n", s, map_range(r1, r2, (double)s));
}</lang>
 
Anonymous user