0
我不知道这或参数适用于咖喱函数,因为参数绑定到主机函数,在这种情况下,这是“我”不相信实际上在任何地方使用。RamdaJS库咖喱语法分解
var _isPlaceholder = require('./_isPlaceholder');
/**
* Optimized internal one-arity curry function.
*
* @private
* @category Function
* @param {Function} fn The function to curry.
* @return {Function} The curried function.
*/
module.exports = function _curry1(fn) {
return function f1(a) {
if (arguments.length === 0 || _isPlaceholder(a)) {
return f1;
} else {
return fn.apply(this, arguments);
}
};
};
var _curry1 = require('./internal/_curry1');
/**
* Creates a new object from a list key-value pairs. If a key appears in
* multiple pairs, the rightmost pair is included in the object.
*
* @func
* @memberOf R
* @since v0.3.0
* @category List
* @sig [[k,v]] -> {k: v}
* @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object.
* @return {Object} The object made by pairing up `keys` and `values`.
* @see R.toPairs, R.pair
* @example
*
* R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
*/
module.exports = _curry1(function fromPairs(pairs) {
var result = {};
var idx = 0;
while (idx < pairs.length) {
result[pairs[idx][0]] = pairs[idx][1];
idx += 1;
}
return result;
});
那么什么是f1,fn的argumens,因为不会在f1中调用参数指的是? – user7863717
'a'和'arguments [0]'都是对同一个参数的引用。如果'isPlaceholder(a)'被替换为'isPlaceholder(arguments [0])'',那么你可以移除'a',但是保留'a'作为参数以便'f1.length == 1'是有用的。 –
所以不是咖喱1(fn)(a)是什么时候a被使用,它是如何引用成对的? – user7863717