From bf6a337a5f943ed69e3f7f3ba0890c28365b0c64 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 26 Nov 2013 02:42:13 -0800 Subject: [PATCH] add pic_cxxr functions --- include/picrin/pair.h | 5 +++++ src/pair.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/picrin/pair.h b/include/picrin/pair.h index 28c722bf..5fd18e62 100644 --- a/include/picrin/pair.h +++ b/include/picrin/pair.h @@ -15,4 +15,9 @@ pic_value pic_reverse(pic_state *, pic_value); pic_value pic_assq(pic_state *, pic_value key, pic_value assoc); pic_value pic_acons(pic_state *, pic_value key, pic_value val, pic_value assoc); +pic_value pic_caar(pic_state *, pic_value); +pic_value pic_cadr(pic_state *, pic_value); +pic_value pic_cdar(pic_state *, pic_value); +pic_value pic_cddr(pic_state *, pic_value); + #endif diff --git a/src/pair.c b/src/pair.c index c1c78af1..193d4c77 100644 --- a/src/pair.c +++ b/src/pair.c @@ -134,6 +134,30 @@ pic_acons(pic_state *pic, pic_value key, pic_value val, pic_value assoc) return pic_cons(pic, pic_cons(pic, key, val), assoc); } +pic_value +pic_caar(pic_state *pic, pic_value v) +{ + return pic_car(pic, pic_car(pic, v)); +} + +pic_value +pic_cadr(pic_state *pic, pic_value v) +{ + return pic_car(pic, pic_cdr(pic, v)); +} + +pic_value +pic_cdar(pic_state *pic, pic_value v) +{ + return pic_cdr(pic, pic_car(pic, v)); +} + +pic_value +pic_cddr(pic_state *pic, pic_value v) +{ + return pic_cdr(pic, pic_cdr(pic, v)); +} + static pic_value pic_pair_pair_p(pic_state *pic) {