summaryrefslogtreecommitdiff
path: root/libguile/srfi-1.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-08-12 23:26:15 +0200
committerAndy Wingo <wingo@pobox.com>2011-08-12 23:26:15 +0200
commite7a81c7acdc0501b3fca6cdd51eb05d4fe39d317 (patch)
tree1814cd0c9636fe024b2f76614c20d9bc477b2811 /libguile/srfi-1.c
parent335c8a89a2e1dfb362b7a52010da4a81ab9cffc9 (diff)
downloadguile-e7a81c7acdc0501b3fca6cdd51eb05d4fe39d317.tar.gz
fix take-right and drop-right for improper lists
* libguile/srfi-1.h: * libguile/srfi-1.c (scm_srfi1_drop_right, scm_srfi1_take_right): Remove these internal functions, replacing with Scheme implementations. * module/srfi/srfi-1.scm (take-right, drop-right): Add these impls from the reference code. They do the right thing for improper lists, according to the spec, but they diverge for circular lists. Oh well. * test-suite/tests/srfi-1.test ("drop-right", "take-right"): Add more tests.
Diffstat (limited to 'libguile/srfi-1.c')
-rw-r--r--libguile/srfi-1.c39
1 files changed, 0 insertions, 39 deletions
diff --git a/libguile/srfi-1.c b/libguile/srfi-1.c
index 37441f788..ed6d3d9d1 100644
--- a/libguile/srfi-1.c
+++ b/libguile/srfi-1.c
@@ -568,28 +568,6 @@ SCM_DEFINE (scm_srfi1_delete_duplicates_x, "delete-duplicates!", 1, 1, 0,
#undef FUNC_NAME
-SCM_DEFINE (scm_srfi1_drop_right, "drop-right", 2, 0, 0,
- (SCM lst, SCM n),
- "Return a new list containing all except the last @var{n}\n"
- "elements of @var{lst}.")
-#define FUNC_NAME s_scm_srfi1_drop_right
-{
- SCM tail = scm_list_tail (lst, n);
- SCM ret = SCM_EOL;
- SCM *rend = &ret;
- while (scm_is_pair (tail))
- {
- *rend = scm_cons (SCM_CAR (lst), SCM_EOL);
- rend = SCM_CDRLOC (*rend);
-
- lst = SCM_CDR (lst);
- tail = SCM_CDR (tail);
- }
- SCM_ASSERT_TYPE (SCM_NULL_OR_NIL_P(tail), tail, SCM_ARG1, FUNC_NAME, "list");
- return ret;
-}
-#undef FUNC_NAME
-
SCM_DEFINE (scm_srfi1_find, "find", 2, 0, 0,
(SCM pred, SCM lst),
"Return the first element of @var{lst} which satisfies the\n"
@@ -924,23 +902,6 @@ SCM_DEFINE (scm_srfi1_remove_x, "remove!", 2, 0, 0,
}
#undef FUNC_NAME
-SCM_DEFINE (scm_srfi1_take_right, "take-right", 2, 0, 0,
- (SCM lst, SCM n),
- "Return a list containing the @var{n} last elements of\n"
- "@var{lst}.")
-#define FUNC_NAME s_scm_srfi1_take_right
-{
- SCM tail = scm_list_tail (lst, n);
- while (scm_is_pair (tail))
- {
- lst = SCM_CDR (lst);
- tail = SCM_CDR (tail);
- }
- SCM_ASSERT_TYPE (SCM_NULL_OR_NIL_P(tail), tail, SCM_ARG1, FUNC_NAME, "list");
- return lst;
-}
-#undef FUNC_NAME
-
void
scm_register_srfi_1 (void)