replace list impl by scheme with impl by C

This commit is contained in:
Yuichi Nishiwaki 2014-01-22 21:20:13 +09:00
parent bbd1ec3fbb
commit 7fc2885fad
2 changed files with 13 additions and 13 deletions

View File

@ -35,8 +35,6 @@
(define-library (picrin bootstrap-tools)
(import (scheme base))
(define (list . args) args)
(define (caar p) (car (car p)))
(define (cadr p) (car (cdr p)))
(define (cdar p) (cdr (car p)))
@ -51,14 +49,7 @@
(cons (f (car list))
(map f (cdr list)))))
(define (append xs ys)
(if (null? xs)
ys
(cons (car xs)
(append (cdr xs) ys))))
(export list map append
caar cadr cdar cddr
(export map caar cadr cdar cddr
cadar caddr cdddr))
;;; core syntaces
@ -475,9 +466,6 @@
(list? (cdr obj))
#f)))
(define (list . args)
args)
(define (caar p)
(car (car p)))

View File

@ -290,6 +290,17 @@ pic_pair_null_p(pic_state *pic)
return pic_bool_value(pic_nil_p(v));
}
static pic_value
pic_pair_list(pic_state *pic)
{
size_t argc;
pic_value *argv;
pic_get_args(pic, "*", &argc, &argv);
return pic_list_from_array(pic, argc, argv);
}
static pic_value
pic_pair_length(pic_state *pic)
{
@ -358,6 +369,7 @@ pic_init_pair(pic_state *pic)
pic_defun(pic, "set-car!", pic_pair_set_car);
pic_defun(pic, "set-cdr!", pic_pair_set_cdr);
pic_defun(pic, "null?", pic_pair_null_p);
pic_defun(pic, "list", pic_pair_list);
pic_defun(pic, "length", pic_pair_length);
pic_defun(pic, "append", pic_pair_append);
pic_defun(pic, "reverse", pic_pair_reverse);