lab11: init
This commit is contained in:
23
lab11/functional.js
Normal file
23
lab11/functional.js
Normal 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user