Created
May 17, 2021 05:27
-
-
Save ihsanbudiman/3b3a570b656553ac0b902a9682d5afb0 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 pluckDeep = (key) => (obj) => | |
key.split('.').reduce((accum, key) => accum[key], obj) | |
const compose = (...fns) => (res) => | |
fns.reduce((accum, next) => next(accum), res) | |
const unfold = (f, seed) => { | |
const go = (f, seed, acc) => { | |
const res = f(seed) | |
return res ? go(f, res[1], acc.concat([res[0]])) : acc | |
} | |
return go(f, seed, []) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment