Skip to content

Instantly share code, notes, and snippets.

@jcalz
Created October 24, 2019 17:18
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 jcalz/686fe3601ae82f0ed7a19baa3b8a627c to your computer and use it in GitHub Desktop.
Save jcalz/686fe3601ae82f0ed7a19baa3b8a627c to your computer and use it in GitHub Desktop.
Tuple manipulation boilerplate
var N = 30;
var a = Array(N).fill(undefined).map((_, i) => i);
var out = [];
out.push("type Add = [" + a.map(i =>
"[" + a.filter(j => (i + j) < N).map(j =>
"'" + (i + j) + "'"
).join(",") + "]"
).join(",") + "];");
out.push("type Sub = [" + a.map(i =>
"[" + a.filter(j => (i - j) >= 0).map(j =>
"'" + (i - j) + "'"
).join(",") + "]"
).join(",") + "];");
out.push("type Tup = [" + a.map(i =>
"[" + Array(i).fill(0).join(",") + "]"
).join(",") + "];");
console.log(out.join("\n"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment