getify / Functional-Light-JS

Pragmatic, balanced FP in JavaScript. @FLJSBook on twitter.
http://FLJSBook.com
Other
16.6k stars 1.96k forks source link

result(..) to result because result is not a function but a value #202

Closed rsgilbert closed 2 years ago

rsgilbert commented 2 years ago

Yes, I promise I've read the Contributions Guidelines (please feel free to remove this line -- if you leave this line here, I'm going to assume you didn't actually read it).

getify commented 2 years ago

In a composition, each intermediate result is in fact a new function.

rsgilbert commented 2 years ago

@getify I don't think so for this case.

// or the ES6 => form
var compose = (...fns) =>
    result =>
        [...fns].reverse().reduce(
            (result,fn) =>
                fn( result )
            , result
        );

The function that created result has already completed and its this result we are bubbling up through successive functions.

getify commented 2 years ago

Eh, ok. I don't think it matters much.