Map range: Difference between revisions
Content deleted Content added
Slight mod to wording of task. |
J |
||
Line 53: | Line 53: | ||
map_value(10) = 0 |
map_value(10) = 0 |
||
</pre> |
</pre> |
||
=={{header|J}}== |
|||
<lang j>maprange=:2 :0 |
|||
'a1 a2'=.m |
|||
'b1 b2'=.n |
|||
b1+((y-a1)*b2-b1)%a2-a1 |
|||
)</lang> |
|||
Or |
|||
<lang j>maprange=:2 :0 |
|||
'a1 a2'=.m |
|||
'b1 b2'=.n |
|||
b1 + ((b2-b1)%a2-a1) * -&a1 |
|||
)</lang> |
|||
Example use: |
|||
<lang j> 2 4 maprange 5 11 (2.718282 3 3.141592) |
|||
7.15485 8 8.42478</lang> |
|||
or |
|||
<lang j> adjust=:2 4 maprange 5 11 |
|||
adjust 2.718282 3 3.141592 |
|||
7.15485 8 8.42478</lang> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
<lang PureBasic>Structure RR |
<lang PureBasic>Structure RR |