From db1f977600c8245ae0e2f2f21003d950016c9114 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 21 Oct 2013 12:03:35 +0900 Subject: [PATCH] add pic_list_p --- include/picrin/pair.h | 1 + src/pair.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/picrin/pair.h b/include/picrin/pair.h index 82584b0c..2d5a02b2 100644 --- a/include/picrin/pair.h +++ b/include/picrin/pair.h @@ -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_cdr(pic_state *, pic_value); +bool pic_list_p(pic_state *, pic_value); pic_value pic_list(pic_state *, size_t, ...); pic_value pic_assq(pic_state *, pic_value key, pic_value assoc); diff --git a/src/pair.c b/src/pair.c index bbd17e5f..63fa1e40 100644 --- a/src/pair.c +++ b/src/pair.c @@ -39,6 +39,15 @@ pic_cdr(pic_state *pic, pic_value obj) 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_assq(pic_state *pic, pic_value key, pic_value assoc) {