Created
October 24, 2019 17:18
-
-
Save jcalz/686fe3601ae82f0ed7a19baa3b8a627c to your computer and use it in GitHub Desktop.
Tuple manipulation boilerplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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