Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto currying #15

Closed
FlorianRappl opened this issue May 27, 2016 · 0 comments
Closed

Auto currying #15

FlorianRappl opened this issue May 27, 2016 · 0 comments
Assignees
Milestone

Comments

@FlorianRappl
Copy link
Owner

Functions that require at least 1 argument and are invoked with

  • 0-arguments will yield the function itself
  • less arguments than required will yield a curried version of itself

Examples. Let's say standard f(x) -> y functions are invoked as f(), then f() -> f, e.g., f()(3) = f(3). This is of course idempotent, such that f()()()()()(3) = f(3). Similarly, if f(x,y) -> z we obtain f() -> f and f(x) -> g where g(y) = f(x, y), e.g., f(3)(2) = f(3, 2) and g = f(5) with g(2) = f(5, 2) and g(0) = f(5, 0).

This will be applied to all automatically inserted (external) functions as well as available standard functions (also e.g., to operators like add or subtract). This also applies to functions that are defined within MAGES.

f = (x, y) => x + y;
g = f(2);
ans = g(3); // same as f(2, 3)

If more arguments are supplied the unnecessary arguments are just ignored. This behavior won't change.

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

No branches or pull requests

1 participant