add pic_list_ref and pic_list_tail
This commit is contained in:
parent
799e26cff0
commit
a443d9e3f6
|
@ -29,6 +29,9 @@ pic_value pic_cadr(pic_state *, pic_value);
|
|||
pic_value pic_cdar(pic_state *, pic_value);
|
||||
pic_value pic_cddr(pic_state *, pic_value);
|
||||
|
||||
pic_value pic_list_tail(pic_state *, pic_value ,int);
|
||||
pic_value pic_list_ref(pic_state *, pic_value, int);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
15
src/pair.c
15
src/pair.c
|
@ -180,6 +180,21 @@ pic_cddr(pic_state *pic, pic_value v)
|
|||
return pic_cdr(pic, pic_cdr(pic, v));
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_list_tail(pic_state *pic, pic_value list, int i)
|
||||
{
|
||||
while (i-- > 0) {
|
||||
list = pic_cdr(pic, list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_list_ref(pic_state *pic, pic_value list, int i)
|
||||
{
|
||||
return pic_car(pic, pic_list_tail(pic, list, i));
|
||||
}
|
||||
|
||||
static pic_value
|
||||
pic_pair_pair_p(pic_state *pic)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue