Map range: Difference between revisions
Added 11l
m (→{{header|AppleScript}}: Tidying.) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 21:
Show additional idiomatic ways of performing the mapping, using tools available to the language.
<br><br>
=={{header|11l}}==
{{trans|Python}}
<lang 11l>F maprange(a, b, s)
R b[0] + (Float(s - a[0]) * (b[1] - b[0]) / (a[1] - a[0]))
L(s) 0..10
print(‘#2 maps to #.’.format(s, maprange((0, 10), (-1, 0), s)))</lang>
{{out}}
<pre>
0 maps to -1
1 maps to -0.9
2 maps to -0.8
3 maps to -0.7
4 maps to -0.6
5 maps to -0.5
6 maps to -0.4
7 maps to -0.3
8 maps to -0.2
9 maps to -0.1
10 maps to 0
</pre>
=={{header|ACL2}}==
|