_p_
//curry
"use strict";
///home/hav/hv/vhost10666/JS/blank/htdocs/c/h/js/std/class2.js
var myApp = myApp || { }; // top-level namespace
$(function() { //start when DOM ready
let msg = "";
msg += "curry example <br/>";
msg += "<a href=\"https://blog.logrocket.com/understanding-javascript-currying/\" target=\"_blank\"> about curry </a><br/>";
let k1 = function(a, b, c){
return ((a + b + c) / 3);
}
let k2 = (a, b, c) => {
return ((a + b + c) / 3);
}
// function kc takes one argument a
// and returns a function that takes another argument b
// and...
let kc = (a) => {
return (b)=>{
return (c)=>{
return ((a + b + c) / 3)
}
}
}
msg += "<pre>";
msg += " no curry_1: k1(4, 5, 6) = " + k1(4, 5, 6) + "<br/>";
msg += " no curry_2: k2(4, 5, 6) = " + k2(4, 5, 6) + "<br/>";
msg += " with curry: kc(4)(5)(6) = " + kc(4)(5)(6) + "<br/>";
msg += "</pre>";
document.getElementById('place').innerHTML = msg;
})