首頁 > 問答 > 主體
最近在看函數式程式設計。用的是ramda函式庫。
但各種api使用一臉懵逼。
1
2
3
4
<code class="js"> var func3=_.compose(p,trace("f3:"), f);
<code
class
=
"js"
>
var
func3=_.compose(p,trace(
"f3:"
), f);
var func4=_.filter(_.compose(p,trace("f4:"), f));
func4=_.filter(_.compose(p,trace(
"f4:"
), f));
console.log(func3(3))//36
console.log(func3(3))
//36
console.log(func4([3]))//[3] why? what happened</code>
console.log(func4([3]))
//[3] why? what happened</code>
某草草2017-07-05 10:44:21
Ramda 會自動柯里化,這麼看可以理解不
<code class="javascript">_.filter(func3, [3])</code>
"javascript"
>_.filter(func3, [3])</code>
func3(3) 回傳 36,也就是 true 了,所以 filter 一遍 3 還在
func3(3)