Skip to content

Instantly share code, notes, and snippets.

@ysm-dev
Created October 23, 2018 06:19
Show Gist options
  • Select an option

  • Save ysm-dev/3157475b8c7f32bf98b3df8045dafa2c to your computer and use it in GitHub Desktop.

Select an option

Save ysm-dev/3157475b8c7f32bf98b3df8045dafa2c to your computer and use it in GitHub Desktop.

Revisions

  1. ysm-dev created this gist Oct 23, 2018.
    12 changes: 12 additions & 0 deletions source.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    // 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, [])
    }