add pic_list_p

This commit is contained in:
Yuichi Nishiwaki 2013-10-21 12:03:35 +09:00
parent 15c4361381
commit db1f977600
2 changed files with 10 additions and 0 deletions

View File

@ -5,6 +5,7 @@ pic_value pic_cons(pic_state *, pic_value, pic_value);
pic_value pic_car(pic_state *, pic_value); pic_value pic_car(pic_state *, pic_value);
pic_value pic_cdr(pic_state *, pic_value); pic_value pic_cdr(pic_state *, pic_value);
bool pic_list_p(pic_state *, pic_value);
pic_value pic_list(pic_state *, size_t, ...); pic_value pic_list(pic_state *, size_t, ...);
pic_value pic_assq(pic_state *, pic_value key, pic_value assoc); pic_value pic_assq(pic_state *, pic_value key, pic_value assoc);

View File

@ -39,6 +39,15 @@ pic_cdr(pic_state *pic, pic_value obj)
return pair->cdr; return pair->cdr;
} }
bool
pic_list_p(pic_state *pic, pic_value obj)
{
while (pic_pair_p(obj))
obj = pic_pair_ptr(obj)->cdr;
return pic_nil_p(obj);
}
pic_value pic_value
pic_assq(pic_state *pic, pic_value key, pic_value assoc) pic_assq(pic_state *pic, pic_value key, pic_value assoc)
{ {