const normalize = (min: number) => (max: number) => (x: number) => (x - min) / (max - min);
// usage
const min = 25;
const max = 100;
const n = normalize(min)(max);
const ns = [32, 62.5, 90].map(n);
console.log(ns); // [0.09333333333333334, 0.5, 0.8666666666666667]
Created
March 28, 2023 23:15
-
-
Save joshwashywash/06f9f08cd764a7a3c10d0c88e5fa138b to your computer and use it in GitHub Desktop.
normalize a range [min, max] to [0, 1]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment