Skip to content

Instantly share code, notes, and snippets.

@kimdwkimdw
Last active September 28, 2019 16:11
Show Gist options
  • Save kimdwkimdw/80a7ddbfeec9a15e8f9614cada5f2ac1 to your computer and use it in GitHub Desktop.
Save kimdwkimdw/80a7ddbfeec9a15e8f9614cada5f2ac1 to your computer and use it in GitHub Desktop.

Revisions

  1. kimdwkimdw renamed this gist Sep 25, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. kimdwkimdw created this gist Sep 25, 2019.
    15 changes: 15 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    const r = 3;
    const comb = [-1, -0.5, 0, 0.5, 1];
    let final_combinations = [];


    ( ( (f) => f(f) )
    ( (f) => (r, v) => {
    if (r) for (let c in comb) { v.push(comb[c]); f(f)(r-1, v); v.pop(); }
    else final_combinations.push(v.slice());
    }
    ))
    (r , [])

    final_combinations[0];
    final_combinations.length; // comb**r