Anonymous user
Map range: Difference between revisions
→{{header|Julia}}
m (→Version 4: changed a comment to reflect that the (old) REXX version is no longer shown (it has been updated).) |
|||
Line 1,163:
=={{header|Julia}}==
{{works with|Julia|0.6}}
julia> maprange(6, 0:10, -1:0)▼
<lang julia>function maprange(
a₁, a₂ = minimum(a), maximum(a)
b₁, b₂ = minimum(b), maximum(b)
return b₁ + (s - a₁) * (b₂ - b₁) / (a₂ - a₁)
end
{{out}}
<pre>maprange(6, 1:10, -1:0) = -0.4444444444444444
maprange(0:10, 0:10, -1:0) = -1.0:0.1:0.0</pre>
=={{header|K}}==
|