File: list_sum.tex

package info (click to toggle)
cadabra 1.46-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,244 kB
  • sloc: cpp: 33,188; ansic: 2,724; makefile: 329; yacc: 180; sh: 157; python: 45; lex: 38; lisp: 19
file content (16 lines) | stat: -rw-r--r-- 466 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
\cdbalgorithm{list\_sum}{}

In an expression containing sums of identical-length lists, create one
new list constructed by adding the elements at the same position in
each list. Example,
\begin{screen}{1,2,3}
{a, b, 7 c + q, d, e} - {-f, g, h, i, j}:
@list_sum!(%):
@sumflatten!(%);
\{ a + f, b - g, 7c + q - h, d - i, e - j \};
\end{screen}
To generate a list of the products of the elements,
use \subscommand{inner} instead.

\cdbseealgo{inner}
\cdbseealgo{range}