mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
50 lines
948 B
Plaintext
50 lines
948 B
Plaintext
NAME
|
|
head - create a list of specified size from the head of a list
|
|
|
|
SYNOPSIS
|
|
head(x, y)
|
|
|
|
TYPES
|
|
x list
|
|
y int
|
|
|
|
return list
|
|
|
|
DESCRIPTION
|
|
If 0 <= y <= size(x), head(x,y) returns a list of size y whose
|
|
elements in succession have values x[[0]]. x[[1]], ..., x[[y - 1]].
|
|
|
|
If y > size(x), head(x,y) is a copy of x.
|
|
|
|
If -size(x) < y < 0, head(x,y) returns a list of size (size(x) + y)
|
|
whose elements in succession have values x[[0]]. x[[1]], ...,
|
|
i.e. a copy of x from which the last -y members have been deleted.
|
|
|
|
If y <= -size(x), head(x,y) returns a list with no members.
|
|
|
|
For any integer y, x == join(head(x,y), tail(x,-y)).
|
|
|
|
EXAMPLE
|
|
> A = list(2, 3, 5, 7, 11)
|
|
> head(A, 2)
|
|
|
|
list (2 members, 2 nonzero):
|
|
[[0]] = 2
|
|
[[1]] = 3
|
|
|
|
> head(A, -2)
|
|
|
|
list (3 members, 3 nonzero):
|
|
[[0]] = 2
|
|
[[1]] = 3
|
|
[[2]] = 5
|
|
|
|
LIMITS
|
|
none
|
|
|
|
LIBRARY
|
|
none
|
|
|
|
SEE ALSO
|
|
tail, segment
|