⚡
Function Composition
Function Composition어려움 함수 +40pts
Problem
Write a function that composes multiple functions from right to left.
Examples
Input:
compose(x => x * 2, x => x + 1)(5)Output:
12💡 (5 + 1) * 2 = 12
Explanation
이 문제는 **함수형 프로그래밍**의 핵심 개념인 **함수 합성(composition)**을 학습합니다. **함수 합성이란?** 여러 함수를 연결하여 하나의 새로운 함수를 만드는 것입니다. 수학의 f(g(x))와 같습니다. **compose의 동작 방식** 오른쪽에서 왼쪽으로 함수를 적용합니다: compose(f, g, h)(x) = f(g(h(x))) **compose(x => x * 2, x => x + 1)(5) 실행** 1. 오른쪽 함수 먼저: 5 + 1 = 6 2. 왼쪽 함수 적용: 6 * 2 = 12 **reduc...
View detailed explanation →Key Concepts
함수 합성 reduceRight 메서드 고차 함수 클로저
Time: O(n) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.