This commit is contained in:
2026-06-08 13:21:57 +02:00
parent 823130e3ac
commit 8bee76328b
23 changed files with 734 additions and 382 deletions
+50 -12
View File
@@ -1,25 +1,63 @@
let answer = 42;
function square(x) {
return x * x;
// random-number
function randomBetween1And5() {
return Math.floor(Math.random() * 5) + 1;
}
function sum_to(n) {
// unique-values
function uniqueValues(xs) {
return Array.from(new Set(xs));
}
// array-at
function arrayAt(xs, i) {
return xs[i];
}
// sum-to
function sumTo(n) {
{
const i7 = 0;
const acc8 = 0;
const i20 = 0;
const acc21 = 0;
{
let i = i7;
let acc = acc8;
let i = i20;
let acc = acc21;
while (true) {
if (i > n) {
return acc;
} else {
const i11 = i + 1;
const acc12 = acc + i;
i = i11;
acc = acc12;
const i24 = i + 1;
const acc25 = acc + i;
i = i24;
acc = acc25;
continue;
}
}
}
}
}
// make-adder
function makeAdder(x) {
return function (y) {
return x + y;
};
}
// set-html
function setHtml(id, html) {
{
const el38 = document.getElementById(id);
{
let el = el38;
el.innerHTML = html;
return el.innerHTML;
}
}
}