Map range: Difference between revisions

Line 3,090:
9 maps to -0.1
10 maps to 0
</pre>
 
=={{header|RPL}}==
Ranges are entered as complex numbers to ease input and shorten code
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! RPL code
! Comment
|-
|
≪ → ra rb s
≪ rb ra - DUP RE SWAP IM /
s ra RE - * rb RE +
≫ ≫ 'MAP' STO
|
''( (a1, a2) (b1, b2) s -- t )''
Get (b2 - b1)/(a2 - a1)
Multiply by (s - a1) and add b1
|}
{{in}}
<pre>
(0,10) (-1,0) 0 MAP
(0,10) (-1,0) 4 MAP
(0,10) (-1,0) 10 MAP
</pre>
{{out}}
<pre>
3: -1
2: -0.6
1: 0
</pre>
 
1,151

edits