Map range: Difference between revisions
Content added Content deleted
(add BQN) |
No edit summary |
||
Line 1,868: | Line 1,868: | ||
9: -0.1 |
9: -0.1 |
||
10: 0.0</pre> |
10: 0.0</pre> |
||
=={{header|Liberty BASIC}}== |
|||
<lang liberty basic>For i = 0 To 10 |
|||
Print "f(";i;") maps to ";mapToRange(i, 0, 10, -1, 0) |
|||
Next i |
|||
Wait |
|||
Function mapToRange(value, inputMin, inputMax, outputMin, outputMax) |
|||
mapToRange = (((value - inputMin) * (outputMax - outputMin)) / (inputMax - inputMin)) + outputMin |
|||
End Function |
|||
</lang> |
|||
<pre>f(0) maps to -1 |
|||
f(1) maps to -0.9 |
|||
f(2) maps to -0.8 |
|||
f(3) maps to -0.7 |
|||
f(4) maps to -0.6 |
|||
f(5) maps to -0.5 |
|||
f(6) maps to -0.4 |
|||
f(7) maps to -0.3 |
|||
f(8) maps to -0.2 |
|||
f(9) maps to -0.1 |
|||
f(10) maps to 0</pre> |
|||
=={{header|Logo}}== |
=={{header|Logo}}== |