通过使用名称而不是运算符来计算函数 [英] Count with function by using names instead of operators
本文介绍了通过使用名称而不是运算符来计算函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该怎样做这样的事情?
四(加(9())) - > 13
我需要遵循完全相同的模式。我想知道如何使用括号。是的,加上也应该是一个单独的方法。
我尝试过:
我实现了类似的方法但仍然需要以不同的方式调用它:
function four(fn){
return fn(4)
}
函数plusNine(arg){
返回9 + arg
}
四(plusNine)///我不能使用括号,是吗? / pre>解决方案
它不能以这种方式工作。
操作员必须知道所有的值,它是唯一的可能性。
唯一的方法是:
plus(four(),nine()) - > 13
否则,唯一的可能性是加上
是独一无二的caseplus
是一个空壳,功能在四
函数中移动。
How can I do something like this?
four(plus(nine()))-> 13
I need to follow the exact same pattern. I would like to know how I can use parentheses. And yeah, plus should be a separate method as well.
What I have tried:
I implemented a similar approach but still I would need to call it differently:
function four (fn) { return fn(4) } function plusNine(arg) { return 9 + arg } four(plusNine) ///I can`t use parentheses, can I?解决方案It can't work this way.
The operator must have knowledge of all the values, it is the only possibility.
the only way is:
plus(four(),nine())-> 13
Otherwise, the only possibility is thatplus
is unique and in thos caseplus
is an empty shell and the functionality is moved in thefour
function.
这篇关于通过使用名称而不是运算符来计算函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文