Map range: Difference between revisions

"in succession" is an unnecessary constraint. Also, it's good to encourage exposition of additional language features related to solving the problem.
m (whitespace)
("in succession" is an unnecessary constraint. Also, it's good to encourage exposition of additional language features related to solving the problem.)
Line 5:
:<math>t = b1 + {(s - a1)(b2 - b1) \over (a2 - a1)}</math>
 
The task is to write a function/subroutine/... that takes two ranges and a real number and returns the mapping of the real number from the first to the second range. Use this function to map the values of the integers 0 to 10 from the range [0, 10] to the range [-1, 0] in succession.
 
'''Extra credit:''' Show additional idiomatic ways of performing the mapping, using tools available to the language.
 
<!-- Someone want to add the LaTeX code? I'm not skilled with LaTeX. (And neither am I :-) -->