⚡
Pipe Function
Pipe Function어려움 함수 +40pts
Problem
Write a pipe function that composes functions from left to right.
Examples
Input:
pipe(x => x + 1, x => x * 2)(5)Output:
12💡 (5 + 1) * 2 = 12
Explanation
이 문제는 **함수 합성(function composition)**의 파이프 패턴을 구현하는 방법을 학습합니다. ## 핵심 개념: 파이프 (Pipe) 파이프는 여러 함수를 왼쪽에서 오른쪽으로 순차적으로 적용합니다. ### 접근 방법 ```javascript function pipe(...fns) { return x => fns.reduce((acc, fn) => fn(acc), x); } ``` ### 동작 원리 ```javascript pipe(f, g, h)(x) = h(g(f(x))) ``` - f(x)의 결과를 g...
View detailed explanation →Key Concepts
함수 합성 pipe reduce 함수형 프로그래밍
Time: O(n) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.