replace list-set! impl with C impl
This commit is contained in:
parent
d07456466d
commit
74088d0130
|
@ -32,6 +32,7 @@ pic_value pic_cddr(pic_state *, pic_value);
|
||||||
|
|
||||||
pic_value pic_list_tail(pic_state *, pic_value ,int);
|
pic_value pic_list_tail(pic_state *, pic_value ,int);
|
||||||
pic_value pic_list_ref(pic_state *, pic_value, int);
|
pic_value pic_list_ref(pic_state *, pic_value, int);
|
||||||
|
void pic_list_set(pic_state *, pic_value, int, pic_value);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,9 +462,6 @@
|
||||||
(cons (car args)
|
(cons (car args)
|
||||||
(make-list (- k 1) (car args))))))
|
(make-list (- k 1) (car args))))))
|
||||||
|
|
||||||
(define (list-set! list k obj)
|
|
||||||
(set-car! (list-tail list k) obj))
|
|
||||||
|
|
||||||
(define (list-copy obj)
|
(define (list-copy obj)
|
||||||
(if (null? obj)
|
(if (null? obj)
|
||||||
obj
|
obj
|
||||||
|
|
20
src/pair.c
20
src/pair.c
|
@ -213,6 +213,12 @@ pic_list_ref(pic_state *pic, pic_value list, int i)
|
||||||
return pic_car(pic, pic_list_tail(pic, list, i));
|
return pic_car(pic, pic_list_tail(pic, list, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pic_list_set(pic_state *pic, pic_value list, int i, pic_value obj)
|
||||||
|
{
|
||||||
|
pic_pair_ptr(pic_list_tail(pic, list, i))->car = obj;
|
||||||
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
pic_pair_pair_p(pic_state *pic)
|
pic_pair_pair_p(pic_state *pic)
|
||||||
{
|
{
|
||||||
|
@ -410,6 +416,19 @@ pic_pair_list_ref(pic_state *pic)
|
||||||
return pic_list_ref(pic, list, i);
|
return pic_list_ref(pic, list, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pic_value
|
||||||
|
pic_pair_list_set(pic_state *pic)
|
||||||
|
{
|
||||||
|
pic_value list, obj;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
pic_get_args(pic, "oio", &list, &i, &obj);
|
||||||
|
|
||||||
|
pic_list_set(pic, list, i, obj);
|
||||||
|
|
||||||
|
return pic_none_value();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_init_pair(pic_state *pic)
|
pic_init_pair(pic_state *pic)
|
||||||
{
|
{
|
||||||
|
@ -431,4 +450,5 @@ pic_init_pair(pic_state *pic)
|
||||||
pic_defun(pic, "reverse", pic_pair_reverse);
|
pic_defun(pic, "reverse", pic_pair_reverse);
|
||||||
pic_defun(pic, "list-tail", pic_pair_list_tail);
|
pic_defun(pic, "list-tail", pic_pair_list_tail);
|
||||||
pic_defun(pic, "list-ref", pic_pair_list_ref);
|
pic_defun(pic, "list-ref", pic_pair_list_ref);
|
||||||
|
pic_defun(pic, "list-set!", pic_pair_list_set);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue