Npt documentation.
Reference: ANSI Common Lisp npt
The following function specifications are described in lisp.h
.
void lisp_cons(addr x, addr car, addr cdr);
void lisp_vector(addr x, size_t size);
void lisp_list(addr x, ...);
void lisp_lista(addr x, ...);
int lisp_getelt_(addr x, addr pos, size_t index);
int lisp_setelt_(addr pos, size_t index, addr value);
int lisp_length_(addr pos, size_t *ret);
int lisp_reverse_(addr x, addr pos);
int lisp_nreverse_(addr x, addr pos);
void lisp_car(addr x, addr list);
void lisp_cdr(addr x, addr list);
void lisp_carcdr(addr x, addr y, addr list);
void lisp_setf_car(addr cons, addr value);
void lisp_setf_cdr(addr cons, addr value);
void lisp_setf_carcdr(addr cons, addr car, addr cdr);
int lisp_string8_(addr x, const void *str);
int lisp_string16_(addr x, const void *str);
int lisp_string32_(addr x, const void *str);
int lisp_string_getc_(addr pos, size_t i, unicode *c);
int lisp_strvect_getc(addr pos, size_t i, unicode *c);
int lisp_strvect_length(addr pos, size_t *ret);
Function of the creating sequense.
void lisp_cons(addr x, addr car, addr cdr);
void lisp_vector(addr x, size_t size);
void lisp_list(addr x, ...);
void lisp_lista(addr x, ...);
lisp_cons
void lisp_cons(addr x, addr car, addr cdr);
: car, cdr, Object
Input: x, hold variable Output
Create a cons object.
If car
is NULL
, NIL
is specified.
If cdr
is NULL
, NIL
is specified.
If the car
is a hold variable, the content is specified.
If the cdr
is a hold variable, the content is specified.
lisp_vector
void lisp_vector(addr x, size_t size);
: size, Length of the sequence.
Input: x, hold variable Output
Create a one-dimensional array object.
It is a special object of type simple-vector
.
lisp_list
void lisp_list(addr x, ...);
: Variable arguments
Input: x, hold variable Output
Creates a list object with variable arguments as elements.
The variable argument takes an addr
and is terminated by NULL
.
If the argument is a hold variable, use the content.
Example.
(x, 10);
lisp_fixnum(y, 20);
lisp_fixnum(z, 30);
lisp_fixnum(x, x, y, z, NULL);
lisp_list
-> (10 20 30) x
lisp_lista
void lisp_lista(addr x, ...);
: Variable arguments
Input: x, hold variable Output
Creates a list object with variable arguments as elements.
This is almost equivalent to list*
in Common Lisp, where the final element is the list cdr.
The variable argument takes an addr
and is terminated with NULL.
Unlike list*
, it returns NIL
if no element is found.
If the argument is a hold variable, use the content.
Example.
(x, 10);
lisp_fixnum(y, 20);
lisp_fixnum(z, 30);
lisp_fixnum(x, x, y, z, NULL);
lisp_lista
-> (10 20 . 30) x
Function of the sequense operation.
int lisp_getelt_(addr x, addr pos, size_t index);
int lisp_setelt_(addr pos, size_t index, addr value);
int lisp_length_(addr pos, size_t *ret);
int lisp_reverse_(addr x, addr pos);
int lisp_nreverse_(addr x, addr pos);
lisp_getelt_
int lisp_getelt_(addr x, addr pos, size_t index);
: pos, sequence
Input: index
Input: x, hold variable
Output: Non-zero when escaping. Return
Returns the index
-th element of the sequence pos
.
If pos
is a hold variable, its contents are used.
lisp_setelt_
int lisp_setelt_(addr pos, size_t index, addr value);
: pos, sequnece
Input: index
Input: value, hold variable
Input: Non-zero when escaping. Return
Sets the index
-th element of the sequence pos
to value
.
If pos
, value
is a hold variable, the content is used.
lisp_length_
int lisp_length_(addr pos, size_t *ret);
: pos, sequence
Input: ret, number of elements
Output: Non-zero when escaping. Return
Returns the number of elements in the sequence pos
.
If pos
is a hold variable, the content is used.
lisp_reverse_
int lisp_reverse_(addr x, addr pos);
: pos, sequence
Input: x, hold variable
Output: Non-zero when escaping. Return
The reverse order of the pos
is returned.
If pos
is a hold variable, the content is used.
Because the sequence is newly created, the original sequence is not destroyed.
lisp_nreverse_
int lisp_nreverse_(addr x, addr pos);
: pos, sequence
Input: x, hold variable
Output: Non-zero when escaping. Return
The reverse order of the pos
is returned.
If pos
is a hold variable, the content is used.
Destroy the sequence without creating a new one.
Function of the cons.
void lisp_car(addr x, addr list);
void lisp_cdr(addr x, addr list);
void lisp_carcdr(addr x, addr y, addr list);
void lisp_setf_car(addr cons, addr value);
void lisp_setf_cdr(addr cons, addr value);
void lisp_setf_carcdr(addr cons, addr car, addr cdr);
lisp_car
void lisp_car(addr x, addr list);
: list
Input: x, hold variable Output
Get the car of the list
.
The list
can be specified with cons or NIL.
lisp_cdr
void lisp_cdr(addr x, addr list);
: list
Input: x, hold variable Output
Get the cdr of the list
.
The list
can be specified with cons or NIL.
lisp_carcdr
void lisp_carcdr(addr x, addr y, addr list);
: list
Input: x, y, hold variable Output
Return car of list
to x
and cdr to y
. The list
can be specified with cons or NIL.
lisp_setf_car
void lisp_setf_car(addr cons, addr value);
: cons
Input: value, Object Input
If value
is a hold variable, the content is used.
Set the value
to the car part of the cons
.
lisp_setf_cdr
void lisp_setf_cdr(addr cons, addr value);
: cons
Input: value, Object Input
If value
is a hold variable, the content is used.
Set the value
to the cdr part of the cons
.
lisp_setf_carcdr
void lisp_setf_carcdr(addr cons, addr car, addr cdr);
: cons
Input: car, cdr, Object Input
If car
, cdr
are hold variables, their contents are used.
Set the car
to the car part of the cons
.
Set the cdr
to the cdr part of the cons
.
Function of the string.
int lisp_string8_(addr x, const void *str);
int lisp_string16_(addr x, const void *str);
int lisp_string32_(addr x, const void *str);
int lisp_string_getc_(addr pos, size_t i, unicode *c);
lisp_string8_
int lisp_string8_(addr x, const void *str);
int lisp_string16_(addr x, const void *str);
int lisp_string32_(addr x, const void *str);
: str, string
Input: x, hold variable
Output: Non-zero when escaping. Return
Returns a string object.
It is a special object of type simple-string
.
str
specifies a string to be stored in the object.
The memory format of str
is as follows.
lisp_string16_
Explained in lisp_string8_
.
lisp_string32_
Explained in lisp_string8_
.
lisp_string_getc_
int lisp_string_getc_(addr pos, size_t i, unicode *c);
: pos, string
Input: i, index
Input: c, character
Output: Non-zero when escaping. Return
Get the value of a character from a strvect
object.
If pos
is a hold variable, the content is used.
Function of strvect
, which is an object for simple-string
.
int lisp_strvect_getc(addr pos, size_t i, unicode *c);
int lisp_strvect_length(addr pos, size_t *ret);
lisp_strvect_getc
int lisp_strvect_getc(addr pos, size_t i, unicode *c);
: pos, Object
Input: i, Index
Input: c, Character
Output: Normal: 0, Error: non-zero Return
Get the value of a character from a strvect
object.
This function is for retrieving a character from a string without escaping.
Unlike lisp_string_getc_
, it does not support array
objects.
If it is not a strvect
type object, the function exits with the return value -1
.
If i
is more than the number of characters, it exits with the return value 1
.
If the character is returned to c
, the function exits with the return value 0
.
lisp_strvect_length
int lisp_strvect_length(addr pos, size_t *ret);
: pos, Object
Input: ret, Length of a string.
Output: Normal: 0, Error: non-zero Return
Get the length of a string from the strvect
object.
This function gets the length of a string without escaping.
Unlike lisp_length_
, it works only with strvect
objects.
If it is not a strvect
type object, the function exits with the return value -1
.
If the length of the string is returned to ret
, the function exits with the return value 0
.