Skip to content

Instantly share code, notes, and snippets.

@doug-numetric
Created July 25, 2017 06:21
Show Gist options
  • Select an option

  • Save doug-numetric/97d874d74a2135f2a3b0dd3b73d99947 to your computer and use it in GitHub Desktop.

Select an option

Save doug-numetric/97d874d74a2135f2a3b0dd3b73d99947 to your computer and use it in GitHub Desktop.

Revisions

  1. doug-numetric created this gist Jul 25, 2017.
    15 changes: 15 additions & 0 deletions functionalFibonacci.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    const { reduce, range, map } = require('lodash/fp')

    const fibinacci =
    num => reduce(
    acc => [
    acc[0] + acc[1],
    acc[0]
    ],
    [1,0],
    range(0, num)
    )[0];

    console.log(map(e => fibinacci(e), [1,2,3,4,5,6,7,8,9]));

    // [ 1, 2, 3, 5, 8, 13, 21, 34, 55 ]