Last active
July 19, 2017 15:23
-
-
Save eezhal92/1712401006db47d0b00c22d9f1d4ef8a to your computer and use it in GitHub Desktop.
findMinMax.js
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
const pluck = key => list => list[key]; | |
const pluckX = pluck('x'); | |
const pluckY = pluck('y'); | |
const groupXAndY = list => { | |
return { | |
listX: list.map(pluckX), | |
listY: list.map(pluckY), | |
}; | |
} | |
export const findMinMax = points => { | |
const { listX, listY } = groupXAndY(points); | |
return { | |
minX: Math.min(Number.MAX_SAFE_INTEGER, ...listX), | |
maxX: Math.max(Number.MIN_SAFE_INTEGER, ...listX), | |
minY: Math.min(Number.MAX_SAFE_INTEGER, ...listY), | |
maxY: Math.max(Number.MIN_SAFE_INTEGER, ...listY), | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment