focus expression text field at startup -> version 1.2
[LeanCalc.git] / help / segment
1 NAME
2     segment - segment from and to specified elements of a list
3
4 SYNOPSIS
5     segment(x, y, z)
6
7 TYPES
8     x           list
9     y, z        int
10
11     return      list
12
13 DESCRIPTION
14     For 0 <= y < size(x) and 0 <= z < size(x), segment(x, y, z)
15     returns a list for which the values of the elements are those
16     of the segment of x from x[[y]] to x[[z]].  If y < z, the
17     new list is in the same order as x; if y > z, the order is
18     reversed.
19
20     If y < z, x == join(head(x,y), segment(x,y,z), tail(x, size(x) - z - 1)).
21
22 EXAMPLE
23     > A = list(2, 3, 5, 7, 11)
24     > segment(A, 1, 3)
25
26     list (3 members, 3 nonzero):
27           [[0]] = 3
28           [[1]] = 5
29           [[2]] = 7
30
31     > segment(A, 3, 1)
32
33     list (3 members, 3 nonzero):
34           [[0]] = 7
35           [[1]] = 5
36           [[2]] = 3
37
38 LIMITS
39     0 <= y < size(x)
40     0 <= z < size(x)
41
42 LINK LIBRARY
43     none
44
45 SEE ALSO
46     head, tail
47