leetcode 30 days js challenge
Medium
Given a function fn
, return a curried version of that function.
A curried function is a function that accepts fewer or an equal number of parameters as the original function and returns either another curried function or the same value the original function would have returned.
In practical terms, if you called the original function like sum(1,2,3)
, you would call the curried version like csum(1)(2)(3)
, csum(1)(2,3)
, csum(1,2)(3)
, or csum(1,2,3)
. All these methods of calling the curried function should return the same value as the original.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= inputs.length <= 1000
inputs[i][j]
<= 1050 <= fn.length <= 1000
inputs.flat().length == fn.length
function parameters explicitly defined
學這麼久今天才知道
function.length
是參數的數量ㄏㄏ
SheepSun, May 14, 2023