Skip to content

Functions should be able to take function parameters #2441

@gwhitney

Description

@gwhitney

Currently: (in the demo REPL on the home page)

nd(func,t) = (func(t+1e-10)-func(t))/1e-10
   nd(func, t)

nd(exp,2)
  Error: Undefined function func

[this came up in investigating PR #2392.]

But given that function objects can be created by function assignment, there doesn't seem to be any particular reason why in evaluation of nd, func can't be bound to the meaning of exp so that this evaluation will work. If there is interest in adding this capability to mathjs, I would be happy to work on a PR (although possibly we will run into some closure/funargs issues -- but since programming languages solve those, I should think mathjs can as well).

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:expressionsIssues about the expression parser, variable scoping etc.feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions