Problem, as an interviewer would state it:
"Implement compose(...fns) and pipe(...fns) — both combine multiple single-argument functions into one, differing only in the ORDER they apply."
Examples:
compose(square, double, addOne)(3); // square(double(addOne(3))) -- right to left
pipe(addOne, double, square)(3); // square(double(addOne(3))) -- left to right, SAME result
Clarifying questions expected:
- Which direction does "compose" apply by real, standard convention — right-to-left, or left-to-right?
- Do the combined functions need to support multiple arguments, or just a single value threaded through?
- What should an empty
fnslist (compose()) return?
Code / implementation expected: Yes — real, direct proof that compose and pipe produce the identical result for the same functions with reversed call order.