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

Create CallExpression / High-Order Functions #628

Closed
8 tasks done
sys27 opened this issue May 7, 2023 · 0 comments · Fixed by #635
Closed
8 tasks done

Create CallExpression / High-Order Functions #628

sys27 opened this issue May 7, 2023 · 0 comments · Fixed by #635
Assignees
Labels
Milestone

Comments

@sys27
Copy link
Owner

sys27 commented May 7, 2023

  • Create a new result type for functions (Lambda)
    The Lambda object will represent a definition of a function without a name and will contain the list of parameters and the code of the function. It could be stored in the parameters collection or returned by other expressions.

  • Add CallExpression
    All functions (except built-in) will be parsed as CallExpression, it will have a reference to Lambda object (the function to call) and the list of actual parameters to pass to the function.
    (f := (y) => sin(y))(pi) -> CallExpression(Lambda, Parameters)
    f(pi) -> CallExpression
    sin(pi) -> Sin

  • Update parser to support lambda functions.
    (x) => sin(x) / lambda = '(' parameters ')' '=>' expression
    f := (x) => sin(x) new type of function declaration???
    (f(x) := sin(x))(pi) vs ((x) => sin(x))(pi)

  • Update parser to support inline lambdas

  • Remove UserFunction
    UserFunctions will be reworked (partially replaced by CallExpression and Lambda). They will be stored in the existing parameter collection instead of a separate one. For example (the parameters collection):
    pi -> 3.14 (NumberValue)
    f -> (x) := sin(x) (Lambda)

  • Support High-Order Functions:
    f(a, b) := a(b)
    f(sin, pi)

  • Update TypeAnalyzer, Simplifier, Differentiator

  • Add references to all existing functions.

@sys27 sys27 added feature proposal Features that are not approved yet labels May 7, 2023
@sys27 sys27 added this to the xFunc 4.2.0 milestone May 7, 2023
@sys27 sys27 self-assigned this May 7, 2023
@sys27 sys27 changed the title Create CallExpression Create CallExpression / High-Order Functions May 7, 2023
@sys27 sys27 removed the proposal Features that are not approved yet label May 12, 2023
@sys27 sys27 closed this as completed in #635 Jun 5, 2023
sys27 added a commit that referenced this issue Jun 5, 2023
#628 - Create CallExpression / High-Order Functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant