[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.5.1 car , cdr , cons , append , reverse , length |
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
car
, cdr
, cons
, append
, reverse
, length
:: The first element of the given non-null list list.
:: A list obtained by removing the first element of the given non-null list list.
:: A list obtained by adding an element obj to the top of the given list list.
:: A list obtained by adding all elements in the list list2 according to the order as it is to the last element in the list list1.
:: reversed list of list.
:: Number of elements in a list list and a vector vect.
car()
: arbitrary, cdr()
, cons()
, append()
, reverse()
: list, length()
: non-negative integer
list
arbitrary
car()
outputs the first element of a non-null list.
For a null list, the result should be undefined. In the current
implementation, however, it outputs a null list. This treatment for a
null list may subject to change in future, and users are suggested not
to use the tentative treatment for a null list for serious programming.
cdr()
outputs a list obtained by removing the first
element from the input non-null list.
For a null list, the result should be undefined. In the current
implementation, however, it outputs a null list. This treatment for a
null list may subject to change in future, and users are suggested not
to use the tentative treatment for a null list for serious programming.
cons()
composes a new list from the input list list
and an arbitrary object obj by adding obj to the top of
list.
append()
composes a new list, which has all elements of
list1 in the same ordering followed by all elements of list2
in the same ordering.
reverse()
returns a reversed list of list.
length()
returns a non-negative integer which is the
number of elements in the input list list and the input vector vect.
Note that function size
should be used for counting elements
of matrix.
cdr()
n times repeatedly and cdr()
at last.
A more convenient way to access to the n-th element is the use
of bracket notation, that is, to attach an index [n]
like vectors and matrices. The system, however, follow the
n pointers to access the desired element. Subsequently, much
time is spent for an element located far from the top of the list.
cdr()
does not create a new cell (a memory quantity).
Function append()
, as a matter of fact, repeats cons()
for as many as the length of list1 the first argument.
Subsequently, append()
consumes much memory space if its
first argument is long.
Similar argument applies to function reverse()
.
[0] L = [[1,2,3],4,[5,6]]; [[1,2,3],4,[5,6]] [1] car(L); [1,2,3] [2] cdr(L); [4,[5,6]] [3] cons(x*y,L); [y*x,[1,2,3],4,[5,6]] [4] append([a,b,c],[d]); [a,b,c,d] [5] reverse([a,b,c,d]); [d,c,b,a] [6] length(L); 3 [7] length(ltov(L)); 3 [8] L[2][0]; 5
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] |
This document was generated on December 22, 2024 using texi2html 5.0.