Skip to content

Instantly share code, notes, and snippets.

@Hasnep
Created June 22, 2024 12:43
Show Gist options
  • Save Hasnep/8b6ecf4c2f1f528f1811d0196fb0f856 to your computer and use it in GitHub Desktop.
Save Hasnep/8b6ecf4c2f1f528f1811d0196fb0f856 to your computer and use it in GitHub Desktop.
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);
package [Example] {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment