failed attempts to intercept copy command when the cursor is in the empty text field...
[LeanCalc.git] / help / sum
1 NAME
2     sum - sum, or sum of defined sums
3
4 SYNOPSIS
5     sum(x_1, x_2, ...)
6
7 TYPES
8     x_1, x_2, ...       any
9
10     return              any
11
12 DESCRIPTION
13     If an argument x_i is a list with elements e_1, e_2, ..., e_n, it
14     is treated as if x_i were replaced by e_1, e_2, ..., e_n; this may
15     continue recurively if any of the e_j is a list.
16
17     If an argument x_i is an object of type xx, then x_i is replaced by
18     xx_sum(x_i) if the function xx_sum() has been defined.  If the
19     type xx has been defined by:
20
21                 obj xx = {x, y, z},
22
23     an appropriate definition of xx_sum(a) is sometimes a.x + a.y + a.z.
24     sum(a) then returns the sum of the elements of a.
25
26     If x_i has the null value, it is ignored.  Thus, sum(a, , b, , c)
27     will return the same as sum(a, b, c).
28
29     Assuming the above replacements, and that the x_1, x_2, ..., are
30     of types for which addition is defined, sum(x_1, x_2, ...) returns
31     the sum of the arguments.
32
33 EXAMPLE
34     > print sum(2), sum(5, 3, 7, 2, 9), sum(3.2, -0.5, 8.7, -1.2, 2.5)
35     2 26 12.7
36
37     > print sum(list(3,5), 7, list(6, list(7,8), 2))
38     38
39
40
41     > obj point {x, y}
42     > define point_add(a,b) = obj point = {a.x + b.x, a.y + b.y}
43     > obj point A = {1, 5}
44     > obj point B = {1, 4}
45     > obj point C = {3, 3}
46     > print sum(A, B, C)
47     obj point {5, 12}
48
49     > define point_sum(a) = a.x
50     > print sum(A, B, C)
51     5
52
53 LIMITS
54     The number of arguments is not to exceed 100.
55
56 LINK LIBRARY
57     NUMBER *qmin(NUMBER *x1, NUMBER *x2)
58
59 SEE ALSO
60     max, obj
61