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