Created
June 22, 2024 12:43
-
-
Save Hasnep/8b6ecf4c2f1f528f1811d0196fb0f856 to your computer and use it in GitHub Desktop.
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
const fs = require("fs"); | |
const numberToLetters = (num) => { | |
let letters = ""; | |
while (num >= 0) { | |
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[num % 26] + letters; | |
num = Math.floor(num / 26) - 1; | |
} | |
return letters; | |
}; | |
const code = | |
` | |
module [exampleFunction] | |
exampleFunction = \\x, y -> | |
when x is | |
` + | |
Array.from(Array(1000).keys()) | |
.map( | |
(x) => | |
" ".repeat(8) + | |
numberToLetters(x) + | |
" ->\n" + | |
" ".repeat(12) + | |
"when y is\n" + | |
Array.from(Array(1000).keys()) | |
.map( | |
(y) => | |
" ".repeat(16) + | |
numberToLetters(y) + | |
" -> " + | |
'"' + | |
numberToLetters((x + 1) * (y + 1)) + | |
'"', | |
) | |
.join("\n"), | |
) | |
.join("\n"); | |
fs.writeFileSync("Example.roc", code); |
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
package [Example] {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment