diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 9f524fa6..da9f3974 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -1,10 +1,3 @@ -; Although looking like a magic, it just works. -(define (car x) - (car x)) - -(define (cdr x) - (cdr x)) - (define (zero? n) (= n 0)) @@ -138,9 +131,6 @@ (every pred (cdr list)) #f))) -(define (null? obj) - (null? obj)) - (define (any pred list) (if (null? list) #f diff --git a/src/pair.c b/src/pair.c index 922a73bb..6d96fcb6 100644 --- a/src/pair.c +++ b/src/pair.c @@ -125,6 +125,46 @@ pic_pair_pair_p(pic_state *pic) return pic_bool_value(pic_pair_p(v)); } +static pic_value +pic_pair_car(pic_state *pic) +{ + pic_value v; + + pic_get_args(pic, "o", &v); + + return pic_car(pic, v); +} + +static pic_value +pic_pair_cdr(pic_state *pic) +{ + pic_value v; + + pic_get_args(pic, "o", &v); + + return pic_cdr(pic, v); +} + +static pic_value +pic_pair_null_p(pic_state *pic) +{ + pic_value v; + + pic_get_args(pic, "o", &v); + + return pic_bool_value(pic_nil_p(v)); +} + +static pic_value +pic_pair_cons(pic_state *pic) +{ + pic_value v,w; + + pic_get_args(pic, "oo", &v, &w); + + return pic_cons(pic, v, w); +} + static pic_value pic_pair_set_car(pic_state *pic) { @@ -157,6 +197,10 @@ void pic_init_pair(pic_state *pic) { pic_defun(pic, "pair?", pic_pair_pair_p); + pic_defun(pic, "car", pic_pair_car); + pic_defun(pic, "cdr", pic_pair_cdr); + pic_defun(pic, "null?", pic_pair_null_p); + pic_defun(pic, "cons", pic_pair_cons); pic_defun(pic, "set-car!", pic_pair_set_car); pic_defun(pic, "set-cdr!", pic_pair_set_cdr); }