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?
Asked
Active
Viewed 462 times
2 Answers
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.

Marco Wahl
- 2,876
- 14
- 16
-
1I think both answers are valid. However I can only accept one. But both get an upvote! :) – Arne Feb 11 '20 at 14:53
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 +

Erik Hetzner
- 765
- 3
- 6
C-u
, followed by the number of entries on the stack, followed by the symbol of the calculation. – Swedgin Feb 06 '20 at 15:08