mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 19:30:36 +02:00
srfi-1 append-reverse: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_append_reverse): delete. * libguile/srfi-1.h (scm_srfi1_append_reverse): delete. * module/srfi/srfi-1.scm: add append-reverse.
This commit is contained in:
parent
c62d2962d4
commit
17281519df
3 changed files with 17 additions and 26 deletions
|
@ -86,31 +86,6 @@ list_copy_part (SCM lst, int count, SCM *dst)
|
|||
#undef FUNC_NAME
|
||||
|
||||
|
||||
SCM_DEFINE (scm_srfi1_append_reverse, "append-reverse", 2, 0, 0,
|
||||
(SCM revhead, SCM tail),
|
||||
"Reverse @var{rev-head}, append @var{tail} to it, and return the\n"
|
||||
"result. This is equivalent to @code{(append (reverse\n"
|
||||
"@var{rev-head}) @var{tail})}, but its implementation is more\n"
|
||||
"efficient.\n"
|
||||
"\n"
|
||||
"@example\n"
|
||||
"(append-reverse '(1 2 3) '(4 5 6)) @result{} (3 2 1 4 5 6)\n"
|
||||
"@end example")
|
||||
#define FUNC_NAME s_scm_srfi1_append_reverse
|
||||
{
|
||||
while (scm_is_pair (revhead))
|
||||
{
|
||||
/* copy first element of revhead onto front of tail */
|
||||
tail = scm_cons (SCM_CAR (revhead), tail);
|
||||
revhead = SCM_CDR (revhead);
|
||||
}
|
||||
SCM_ASSERT_TYPE (SCM_NULL_OR_NIL_P (revhead), revhead, SCM_ARG1, FUNC_NAME,
|
||||
"list");
|
||||
return tail;
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
||||
SCM_DEFINE (scm_srfi1_append_reverse_x, "append-reverse!", 2, 0, 0,
|
||||
(SCM revhead, SCM tail),
|
||||
"Reverse @var{rev-head}, append @var{tail} to it, and return the\n"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include "libguile/scm.h"
|
||||
|
||||
SCM_INTERNAL SCM scm_srfi1_append_reverse (SCM revhead, SCM tail);
|
||||
SCM_INTERNAL SCM scm_srfi1_append_reverse_x (SCM revhead, SCM tail);
|
||||
SCM_INTERNAL SCM scm_srfi1_count (SCM pred, SCM list1, SCM rest);
|
||||
SCM_INTERNAL SCM scm_srfi1_delete_duplicates (SCM lst, SCM pred);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue