Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
10
Task/Map-range/Vala/map-range.vala
Normal file
10
Task/Map-range/Vala/map-range.vala
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
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() {
|
||||
const double[] r1 = {0.0, 10.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));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue