β‘
Currying
Curryingμ΄λ €μ ν¨μ +40pts
Problem
Write a curry function that transforms a function into its curried form.
Examples
Input:
curry((a, b, c) => a + b + c)(1)(2)(3)Output:
6Explanation
μ΄ λ¬Έμ λ **컀λ§(currying)** ν¨ν΄μ νμ΅ν©λλ€. ν¨μν νλ‘κ·Έλλ°μ ν΅μ¬ κΈ°λ² μ€ νλμ λλ€. **컀λ§μ΄λ?** μ¬λ¬ μΈμλ₯Ό λ°λ ν¨μλ₯Ό νλμ© μΈμλ₯Ό λ°λ ν¨μλ€μ 체μΈμΌλ‘ λ³ννλ κ²μ λλ€: `f(a, b, c)` β `f(a)(b)(c)` **λμ μ리** 1. νμ¬κΉμ§ λ°μ μΈμ κ°μμ νμν μΈμ κ°μ λΉκ΅ 2. μΆ©λΆνλ©΄ μλ³Έ ν¨μ μ€ν 3. λΆμ‘±νλ©΄ λ λ§μ μΈμλ₯Ό λ°λ μ ν¨μ λ°ν **curry((a, b, c) => a + b + c)(1)(2)(3) μ€ν** 1. curried(1): args=[...
View detailed explanation βKey Concepts
μ»€λ§ ν¨ν΄ fn.length μμ± μ¬κ·μ ν¨μ λ°ν λΆλΆ μ μ©
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.