Skip to content

Chapter 3 - Compose function #112

@jamespavett

Description

@jamespavett

Hello, not really an issue but something I am just unsure about.

const compose = (...fns) =>
      (arg) =>
      fns.reduce(
        (composed, f) => f(composed),
        arg
    )

In chapter 3 compose is shown to use the array reduce function, along with being discussed that way in the next.

Doesn't this differ from tradition convention though. Using reduce is traditionally a pipe as it operating left-to-right. The name compose is usually used for a right-to-left pipe where reduceRight is used. Just including the following link as an example of what I mean: https://aparnajoshi.netlify.app/javascript-pipe-and-compose-functions

Obviously is this book compose is being used for reduce operations acting left-to-right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions