Skip to content

Instantly share code, notes, and snippets.

@MattMS
Last active March 21, 2019 12:34
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 MattMS/2106a7ec2fbc3e2caec1dd10f2d96184 to your computer and use it in GitHub Desktop.
Save MattMS/2106a7ec2fbc3e2caec1dd10f2d96184 to your computer and use it in GitHub Desktop.
Simplify calling curried functions.

Eat

Use eat to simplify calling curried functions.

You can rewrite a(b)(c) as eat(a, b, c).

CoffeeScript

eat = (curries...)->
	curries = curries[0] if Array.isArray curries[0]
	curries.reduce (f, v)-> f v

EcmaScript

const eat = (...curries) => (Array.isArray(curries[0]) ? curries[0] : curries).reduce((f, v) => f(v));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment