Created
November 21, 2017 23:11
-
-
Save lcarsos/42d5e40ea4f579509fc49d6fbd7cf8f3 to your computer and use it in GitHub Desktop.
Two range calculating functions using idiomatic ES6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const stepout = (min, max, step = 1) => ( | |
Array( Math.floor((max - min) / step) ).fill().map( ( _, i ) => min + (i * step) ) | |
); | |
export const linspace = (min, max, n = 100) => { | |
const step = (max - min) / (n - 1); | |
return Array( n ).fill().map( ( _, i ) => min + (i * step) ); | |
}; | |
export default stepout; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment