Created
March 11, 2018 09:24
-
-
Save slikts/07c826d9dd8c25628dd4d31f517bc5e7 to your computer and use it in GitHub Desktop.
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
const compose = (f, g) => a => f(g(a)); | |
const takeUntil = (f, xs) => xs.slice(0, xs.findIndex(f)); | |
const id = a => a; | |
const not = a => !a; | |
const takeWhile = (f, xs) => takeUntil(compose(not, f), xs); | |
const takeTruthy = xs => takeWhile(id, xs); |
Author
slikts
commented
Mar 11, 2018
const walk = (f, [x, ...xs], ys = []) => {
const y = f(x)
return y ? walk(f, xs, ys.concat(y)) : ys
}
// const walk = (f, [x, ...xs], ys = []) => (x = f(x)) ? walk(f, xs, ys.concat(x)) : ys
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment