Last active
April 11, 2016 21:29
-
-
Save nicoespeon/d863696342119a70a97b654111249a7b to your computer and use it in GitHub Desktop.
Blog - Achieving point-free JavaScript - introducing point-free style programming
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
// From https://github.com/MostlyAdequate/mostly-adequate-guide/blob/master/ch5.md#pointfree | |
// Not point-free because we mention the data: name | |
let initials = (name) => name.split(' ').map(compose(toUpperCase, head)).join('. '); | |
// Point-free style | |
let initials = compose( | |
join('. '), | |
map(compose(toUpperCase, head)), | |
split(' ') | |
); | |
initials("hunter stockton thompson"); | |
// 'H. S. T' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment