Skip to content

Instantly share code, notes, and snippets.

@gimdongwoo
Created October 28, 2018 04:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gimdongwoo/e3c8aacdb9c7a9b61d0b002ffa006e21 to your computer and use it in GitHub Desktop.
Save gimdongwoo/e3c8aacdb9c7a9b61d0b002ffa006e21 to your computer and use it in GitHub Desktop.
// This is javascript code.
const pluckDeep = key => obj => key.split('.').reduce((accum, key) => accum[key], obj)
const compose = (...fns) => res => fns.reduce((accum, next) => next(accum), res)
// Yeah!
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