Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript _uu_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_uu?为什么它在这里工作?_Javascript_Node.js_Functional Programming_Ramda.js - Fatal编程技术网

Javascript _uu_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_uu?为什么它在这里工作?

Javascript _uu_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_u_uu?为什么它在这里工作?,javascript,node.js,functional-programming,ramda.js,Javascript,Node.js,Functional Programming,Ramda.js,我试图理解为什么在这段代码中工作得很好: function editAddress (id, addressId, model) { return BusinessService .getById(id) .then(unless( () => checkUrlValue(addressId, model.id), rejectWithError(InvalidData.error('Invalid address data:

我试图理解为什么在这段代码中工作得很好:

function editAddress (id, addressId, model) {
    return BusinessService
      .getById(id)
      .then(unless(
        () => checkUrlValue(addressId, model.id),
        rejectWithError(InvalidData.error('Invalid address data: Address id is different from request'))
      ))
      .then(pipe(
        updateModel(__, 'addresses', model, 'id', addressId),
        juxt([ always(id), identity ]),
        apply(BusinessService.editById)
      ))
      .then(pipe(
        prop('addresses'),
        find(propEq('id', addressId))
      ))
  }

既然调用的函数(updateModel)没有curry,为什么在这种情况下
\uuuu
仍然有效?

updateModel
没有curry,但它返回的是curry调用的函数
evolve
的结果。第一个呼叫传入:

{
    [property]: pipe(
      juxt([
        findIndex(propEq(attr, id)),
        pipe(
          find(propEq(attr, id)),
          mergeLeft(model)
        ),
        identity
      ]),
      apply(update)
    )
}

然后,调用Evolution的结果将与
实体一起调用,在您的情况下,实体将是u u;。如果看不到
的内在发展
就不可能进一步理解代码。

有趣的是,我从未注意到这种行为。但解释完全正确。并且,请说明原因。当您将占位符作为最后一个参数传递给
evolve
(或任何其他curried函数)时,它本质上是一个no-op,返回一个函数,该函数相当于只提供前面的参数所得到的函数。但我以前从未见过这样的动作。啊,有道理。。。谢谢你的解释,每天都是上学的日子!有趣的问题。我从未见过这种行为,我是拉姆达的创始人之一。威尔·詹金斯(Will Jenkins)的回答解释了这一点,我的评论对此进行了扩展。但很高兴知道这会奏效。
{
    [property]: pipe(
      juxt([
        findIndex(propEq(attr, id)),
        pipe(
          find(propEq(attr, id)),
          mergeLeft(model)
        ),
        identity
      ]),
      apply(update)
    )
}