int

int, function

def pure int(r: ranvar, a: number, b: number): number
def pure int(z: zedfunc, a: number, b: number): number

Returns the sum of values over the inclusive segment [a, b] for a ranvar or zedfunc.

Examples

r = poisson(3)

table T = with
  [| as A, as B |]
  [| 0, 0 |]
  [| 0, 2 |]
  [| 2, 4 |]

T.Sum = int(r, T.A, T.B)

show table "Ranvar" with
  T.A
  T.B
  T.Sum

This produces the following table:

A B Sum
0 0 0.04978787
0 2 0.4231969
2 4 0.6161249
z = max(constant(5) - linear(1), 0)

table T = with
  [| as A, as B |]
  [| 0, 1 |]
  [| 2, 4 |]

T.Sum = int(z, T.A, T.B)

show table "Zedfunc" with
  T.A
  T.B
  T.Sum

This produces the following table:

A B Sum
0 1 9
2 4 6

For a zedfunc, reversing the bounds negates the sum. Both endpoints remain included, and equal bounds return the value at that single integer:

z = constant(1)

show summary "Inclusive bounds" with
  int(z, -2, 2) as "Forward" // 5
  int(z, 2, -2) as "Reversed" // -5
  int(z, 2, 2) as "Single point" // 1