File: list_sum.tex

package info (click to toggle)
cadabra2 2.3.6.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 77,508 kB
  • sloc: ansic: 132,438; cpp: 86,549; python: 1,365; javascript: 191; xml: 182; sh: 180; objc: 53; makefile: 38
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}