2

Sometimes I just want to sum a bunch of numbers in calc. Right now I press + until the stack is empty. Is there a shorthand for this?

  • 3
    You can use the prefix C-u, followed by the number of entries on the stack, followed by the symbol of the calculation. – Swedgin Feb 6 '20 at 15:08
3

Another solution, if you know from the beginning that you want a sum, is use a vector. Prefix your list of numbers with [, finish with ], and sum using calc-reduce with the + operator (v R +):

[
1
2
...
]
v R +
3

Summing the whole stack of calc can be achieved using a keyboard macro.

  • Define the macro (which does just the + operation): C-x ( + C-x ).
    • BTW this definition already sums two elements of the stack as a side effect.
  • Then run the macro until an error occurs with C-0 X.
  • That's it! The error is expected to occur when one element remains on the stack.

If you know the stack size you possibly better use the suggestion of swedgin.

  • 1
    I think both answers are valid. However I can only accept one. But both get an upvote! :) – Arne Feb 11 '20 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.