Skip to content

Instantly share code, notes, and snippets.

@kimdwkimdw
Last active September 28, 2019 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimdwkimdw/80a7ddbfeec9a15e8f9614cada5f2ac1 to your computer and use it in GitHub Desktop.
Save kimdwkimdw/80a7ddbfeec9a15e8f9614cada5f2ac1 to your computer and use it in GitHub Desktop.
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
@ducky-hong
Copy link

y combinator 인가요? 😃

@kimdwkimdw
Copy link
Author

딱 그런 비슷한게 필요했어서 ㅎㅎ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment