Skip to content

Instantly share code, notes, and snippets.

@gilesbradshaw
Last active January 24, 2019 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilesbradshaw/8b51aa062d94bd0546071195d1fee5c1 to your computer and use it in GitHub Desktop.
Save gilesbradshaw/8b51aa062d94bd0546071195d1fee5c1 to your computer and use it in GitHub Desktop.
currying compose

given

const compose = (...functions) =>
  (...params) =>
    functions
      .reduce(
        (acc, func) => [func(...acc)],
        params,
      )[0]

then

a => b => (
  ...params
) =>
  a(
    b(
      ...params,
    ),
  )

is equivalent to

 a =>
  b => compose(b, a)

why is the a and b swapped in the compose?

@gilesbradshaw
Copy link
Author

the compose is a pipe!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment