Skip to content

Allow specifying / calling functions with positional parameters #359

@cdp330

Description

@cdp330

Currently, calling functions seems to work like you are substituting symbols in an expression, e.g.

If $$y_{2}=x^{2}$$, then to get $$y(3)$$ we need to explictly type

$$y(x=3)$$

While this is convenient and intuitive for some expressions, it becomes annoying for others, because I have to specify the arguments at the call site every time.

This becomes especially inconvenient when integrating or summing user-defined functions, e.g.

If $$P_{X}=p\cdot\left(1-p\right)^{k-1}$$

then I can't write

$$\sum_{k=1}^7 \left( P_{X} \left( k \right) \right) $$

I have to write

$$\sum_{i=1}^7 \left( P_{X} \left( k = i \right) \right)$$

This is both annoying to type and hard to read, because of the temporary $$i$$ variable. What's more, as sheets become complex, it becomes harder to come up with unique names for temporary variables like $$i$$.

I propose a way to specify positional arguments for functions. This should work for both univariate and multivariable functions. For example, we could define $$length(x,y)=\sqrt{x^2 + y^2}$$, and call it via both

$$length (3,4)$$ or $$length(x=3, y=4)$$.

It would also be nice to be able to define multiple functions that use the same parameter names. For example, alongside with $$length(x,y)$$, you should be able to define $$length3D(x,y,z)$$.

Defining functions like this with the new Python Extensions feature is already possible, I would also like to be able to do it with functions written in normal notation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions