File: list_sum.tex

package info (click to toggle)
cadabra2 2.4.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 78,732 kB
  • sloc: ansic: 133,450; cpp: 92,064; python: 1,530; javascript: 203; sh: 184; xml: 182; objc: 53; makefile: 51
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}