Initial revision
[LeanCalc.git] / help / head
1 NAME
2     head - create a list of specified size from the head of a list
3
4 SYNOPSIS
5     head(x, y)
6
7 TYPES
8     x           list
9     y           int
10
11     return      list
12
13 DESCRIPTION
14     If 0 <= y <= size(x), head(x,y) returns a list of size y whose
15     elements in succession have values x[[0]]. x[[1]], ..., x[[y - 1]].
16
17     If y > size(x), head(x,y) is a copy of x.
18
19     If -size(x) < y < 0, head(x,y) returns a list of size (size(x) + y)
20     whose elements in succession have values x[[0]]. x[[1]], ...,
21     i.e. a copy of x from which the last -y members have been deleted.
22
23     If y <= -size(x), head(x,y) returns a list with no members.
24
25     For any integer y, x == join(head(x,y), tail(x,-y)).
26
27 EXAMPLE
28     > A = list(2, 3, 5, 7, 11)
29     > head(A, 2)
30
31     list (2 members, 2 nonzero):
32           [[0]] = 2
33           [[1]] = 3
34
35     > head(A, -2)
36
37     list (3 members, 3 nonzero):
38           [[0]] = 2
39           [[1]] = 3
40           [[2]] = 5
41
42 LIMITS
43     none
44
45 LINK LIBRARY
46     none
47
48 SEE ALSO
49     tail, segment
50