Skip to content

Instantly share code, notes, and snippets.

@ho1234c
Created October 20, 2018 17:11
Show Gist options
  • Save ho1234c/5d5cc4ea2a0e25bd2079bf099342d1f2 to your computer and use it in GitHub Desktop.
Save ho1234c/5d5cc4ea2a0e25bd2079bf099342d1f2 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)
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