Skip to content

Instantly share code, notes, and snippets.

@baweaver
Created October 9, 2017 01:23
Show Gist options
  • Save baweaver/152e6a830c0813cd2d10bc1d05b41553 to your computer and use it in GitHub Desktop.
Save baweaver/152e6a830c0813cd2d10bc1d05b41553 to your computer and use it in GitHub Desktop.
const musicalEraAliveIn = (startLife, endLife) => {
const life = range(startLife, endLife);
const yearsAliveIn = compose(length, intersection(life));
const largestBy = compose(nth(0), reverse, sortBy);
return largestBy(compose(yearsAliveIn, nth(1)), [
['Medieval', range(476, 1400)],
['Renaissance', range(1400, 1600)],
['Baroque', range(1600, 1760)],
['Classical', range(1730, 1820)],
['Romantic', range(1815, 1910)],
['Modern', range(1900, 2100)]
])[0];
};
musicalEraAliveIn(1800, 1950); // => Romantic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment