Map range: Difference between revisions

Changed to a function
m (J: add comments)
(Changed to a function)
Line 115:
{{incorrect|PicoLisp|Task asks for a generic function of two input ranges and a value.}}
<lang PicoLisp>(scl 1)
 
(let (A1 0 A2 10.0 B1 -1.0 B2 0)
(de mapRange (for Val (rangeA1 0A2 10.0B1 1.0B2)
(+ B1 (*/ (- Val A1) (- B2 B1) (- A2 A1))) )
(prinl
 
(format
 
(+ B1 (*/ (- Val A1) (- B2 B1) (- A2 A1)))
(for Val (range 0 10.0 1.0)
*Scl ) ) ) )</lang>
(prinl
(format (mapRange Val 0 10.0 -1.0 0) *Scl ) ) ) )</lang>
Output:
<pre>-1.0
Anonymous user