add vector procedure
This commit is contained in:
parent
2ad517be84
commit
45d894d9f8
20
vector.c
20
vector.c
|
@ -48,6 +48,25 @@ pic_vec_vector_p(pic_state *pic)
|
|||
return pic_bool_value(pic_vec_p(v));
|
||||
}
|
||||
|
||||
static pic_value
|
||||
pic_vec_vector(pic_state *pic)
|
||||
{
|
||||
size_t argc;
|
||||
pic_value *argv;
|
||||
pic_vec *vec;
|
||||
size_t i;
|
||||
|
||||
pic_get_args(pic, "*", &argc, &argv);
|
||||
|
||||
vec = pic_make_vec(pic, argc);
|
||||
|
||||
for (i = 0; i < argc; ++i) {
|
||||
vec->data[i] = argv[i];
|
||||
}
|
||||
|
||||
return pic_obj_value(vec);
|
||||
}
|
||||
|
||||
static pic_value
|
||||
pic_vec_make_vector(pic_state *pic)
|
||||
{
|
||||
|
@ -313,6 +332,7 @@ void
|
|||
pic_init_vector(pic_state *pic)
|
||||
{
|
||||
pic_defun(pic, "vector?", pic_vec_vector_p);
|
||||
pic_defun(pic, "vector", pic_vec_vector);
|
||||
pic_defun(pic, "make-vector", pic_vec_make_vector);
|
||||
pic_defun(pic, "vector-length", pic_vec_vector_length);
|
||||
pic_defun(pic, "vector-ref", pic_vec_vector_ref);
|
||||
|
|
Loading…
Reference in New Issue