lab11: init

This commit is contained in:
2026-04-05 18:43:43 -07:00
parent a5845d69b6
commit dc881101eb
2 changed files with 148 additions and 0 deletions

23
lab11/functional.js Normal file
View File

@@ -0,0 +1,23 @@
var foldl = function (f, acc, array) {
}
console.log(foldl(function(x,y){return x+y}, 0, [1,2,3]));
var foldr = function (f, z, array) {
}
console.log(foldl(function(x,y){return x/y}, 1, [2,4,8]));
var map = function (f, array) {
}
console.log(map(function(x){return x+x}, [1,2,3,5,7,9,11,13]));
// Write a curry function as we discussed in class.
// Create a `double` method using the curry function
// and the following `mult` function.
function mult(x,y) {
return x * y;
}