Is there a ready function in std lib which maps a ...
# getting-started
l
Is there a ready function in std lib which maps a value from one range (say
0..1
) to another range (say
1_000..5_000
)? Basically the equivalent of this:
Copy code
fun getRangeValueAtInterval(start: Int, end: Int, interval: Float): Int =
    start + (interval * (end - start)).roundToInt()
Also as you see here I map from a
Float
range to an
Int
range.
j
I don't believe there is any such thing. IMO it is simple enough to be implemented in user code, and too niche to deserve to be in the stdlib, so I guess that's why there is probably nothing in the stdlib in this respect.
👍 2