Last active
November 16, 2015 16:14
-
-
Save syzer/907e2489dbb978212c73 to your computer and use it in GitHub Desktop.
map without ifs , and loops
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
// here condR === undefined | |
const falsy = (condL, condR) => condL !== condR; | |
const map = (fn, [first, ...rest]) => | |
(falsy(first) && []) && [fn(first), ...map(fn, rest)]; | |
console.log(':)', map((x) => (x + x), [1, 2, 3])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment