You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand the desire to avoid functions, but they do allow code reuse. A happy medium would be formulae, that is names attached to a specific expression. It could be as simple as
> sqr := a * a
formula sqr created
> a = 5
ans = 5.0
> sqr
ans = 25.0
or, with a little more work, as nice as
> sqr(a) := a * a
formula sqr created
> sqr(5)
ans = 25.0
The text was updated successfully, but these errors were encountered:
Let me think about this one! Obviously, I pointed out in the help file why I didn't want to go down the path of user defined functions. I do quite like the idea, however, of labelled expressions that can be re-evaluated by evaluating the label.
The problem with adding parameters, your second example, is to do with complexity. With the first example it is obvious that a is a global and there is only one global scope. By adding parameters you would really then need to then add lexical scope.
Without conditionals recursion doesn't make sense either and so is an issue and would need to be handled carefully.
In the meantime: you can hit enter on an old expression to have it re-evaluate with any newly-bound variables.
Another approach could be defining new functions through vim script.
Currently I'm doing this through Ctrl-r =, but this leaves no history of the function called or its parameters.
One possibility is that function sqr() is defined on .vimrc and it is called on VimCalc inside single quotes: > 'x = sqr(a)' x = 9
For sure the computation inside sqr() would be restrict to the floating point limits of vim instead of python, but I believe that would still be helpful.
I understand the desire to avoid functions, but they do allow code reuse. A happy medium would be formulae, that is names attached to a specific expression. It could be as simple as
or, with a little more work, as nice as
The text was updated successfully, but these errors were encountered: