DRAFT core: Add core:append-reverse, export append-reverse in srfi-1.
* src/core.c (append_reverse_): New procedure. * include/mes/builtins.h: Declare it. * src/builtins.c (mes_builtins): Register it. * mes/module/srfi/srfi-1.scm (append-reverse): Use it in new procedure.
This commit is contained in:
parent
731b9bd4e0
commit
c673b5cc37
|
@ -38,7 +38,7 @@ struct scm *acons (struct scm *key, struct scm *value, struct scm *alist);
|
|||
struct scm *length (struct scm *x);
|
||||
struct scm *error (struct scm *key, struct scm *x);
|
||||
struct scm *append2 (struct scm *x, struct scm *y);
|
||||
struct scm *append_reverse (struct scm *x, struct scm *y);
|
||||
struct scm *append_reverse_ (struct scm *x, struct scm *y);
|
||||
struct scm *reverse_x_ (struct scm *x, struct scm *t);
|
||||
struct scm *assq (struct scm *x, struct scm *a);
|
||||
struct scm *assoc (struct scm *x, struct scm *a);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
find
|
||||
filter
|
||||
append-map
|
||||
append-reverse
|
||||
filter-map
|
||||
fold
|
||||
fold-right
|
||||
|
@ -52,6 +53,8 @@
|
|||
reverse!
|
||||
take-while))
|
||||
|
||||
(define append-reverse core:append-reverse)
|
||||
|
||||
(define (drop-right lst n)
|
||||
(list-head lst (- (length lst) n)))
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ mes_builtins (struct scm *a) /*:((internal)) */
|
|||
a = init_builtin (builtin_type, "length", 1, &length, a);
|
||||
a = init_builtin (builtin_type, "error", 2, &error, a);
|
||||
a = init_builtin (builtin_type, "append2", 2, &append2, a);
|
||||
a = init_builtin (builtin_type, "append-reverse", 2, &append_reverse, a);
|
||||
a = init_builtin (builtin_type, "core:append-reverse", 2, &append_reverse_, a);
|
||||
a = init_builtin (builtin_type, "core:reverse!", 2, &reverse_x_, a);
|
||||
a = init_builtin (builtin_type, "assq", 2, &assq, a);
|
||||
a = init_builtin (builtin_type, "assoc", 2, &assoc, a);
|
||||
|
|
|
@ -178,12 +178,12 @@ append2 (struct scm *x, struct scm *y)
|
|||
}
|
||||
|
||||
struct scm *
|
||||
append_reverse (struct scm *x, struct scm *y)
|
||||
append_reverse_ (struct scm *x, struct scm *y)
|
||||
{
|
||||
if (x == cell_nil)
|
||||
return y;
|
||||
if (x->type != TPAIR)
|
||||
error (cell_symbol_not_a_pair, cons (x, cstring_to_symbol ("append-reverse")));
|
||||
error (cell_symbol_not_a_pair, cons (x, cstring_to_symbol ("core:append-reverse")));
|
||||
while (x != cell_nil)
|
||||
{
|
||||
y = cons (x->car, y);
|
||||
|
|
Loading…
Reference in New Issue