lab19: init

This commit is contained in:
2026-04-29 11:33:23 -07:00
parent d042a0e016
commit dba2c2b3d6
12 changed files with 386 additions and 0 deletions

17
lab19/withProb.js Normal file
View File

@@ -0,0 +1,17 @@
function withProb(prob, f) {
if (Math.random() < prob) {
return f();
}
}
function foo(x) {
withProb(0.5, function() {
console.log("Execution withProb callback");
return 0;
});
return x;
}
console.log("Foo is " + foo(1));