-
-
Save coderbyheart/35ae09cde55c67735a6b7ec27e5a474c to your computer and use it in GitHub Desktop.
pokemon-kata.js
This file contains 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
it("should find the name of the nearest Pokemon", () => { | |
const monNames = pluck('name') | |
const monDistances = R.pipe(pluck('position'), map(distance(playerPosition))) | |
const nameAndDistancePair = curryN(2, zip)( | |
monNames(mons), | |
monDistances(mons) | |
) | |
const nearestMon = R.reduce((mon, nearestMon) => { | |
return mon[1] < nearestMon[1] ? mon : nearestMon | |
}, Infinity) | |
const nearestPokemonName = R.pipe(nearestMon, nth(0)) | |
expect(nearestPokemonName(nameAndDistancePair)).toEqual('Magikarp') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment