Map range: Difference between revisions
Content added Content deleted
(add BQN) |
|||
Line 665: | Line 665: | ||
=> 0.000000</pre> |
=> 0.000000</pre> |
||
=={{header|BQN}}== |
|||
A direct implementation of the specification. |
|||
<code>_map_</code> is a 2-modifier which returns a mapping function given two ranges. |
|||
<lang bqn>_map_ ← { |
|||
a1‿a2 _𝕣_ b1‿b2 s: |
|||
b1 + ((s - a1) × b2 - b1) ÷ a2 - a1 |
|||
} |
|||
ZeroTen ← 0‿10 _map_ ¯1‿0 |
|||
•Show ZeroTen 0.1 |
|||
•Show ZeroTen 8</lang> |
|||
<lang bqn>¯0.99 |
|||
¯0.19999999999999996</lang> |
|||
[https://mlochbaum.github.io/BQN/try.html#code=X21hcF8g4oaQIHsKIGEx4oC/YTIgX/CdlaNfIGIx4oC/YjIgczoKIGIxICsgKChzIC0gYTEpIMOXIGIyIC0gYjEpIMO3IGEyIC0gYTEKfQoKWmVyb1RlbiDihpAgMOKAvzEwIF9tYXBfIMKvMeKAvzAKCuKAolNob3cgWmVyb1RlbiAwLjEK4oCiU2hvdyBaZXJvVGVuIDEw Try It!] |
|||
=={{header|Bracmat}}== |
=={{header|Bracmat}}== |
||
{{trans|C}} |
{{trans|C}} |