summaryrefslogtreecommitdiff
path: root/libguile/srfi-1.c
diff options
context:
space:
mode:
authorRob Browning <rlb@defaultvalue.org>2024-07-17 22:12:22 -0500
committerRob Browning <rlb@defaultvalue.org>2024-07-30 19:28:37 -0500
commit925faf1f01106e468dde78c453595575904bc158 (patch)
treee2dd49320db92a7c84404792faa27eaf5bca435a /libguile/srfi-1.c
parent58246aee24be908307117b3f8ae8040460f86ce7 (diff)
downloadguile-925faf1f01106e468dde78c453595575904bc158.tar.gz
srfi-1 partition: move from C to Scheme
* libguile/srfi-1.c (scm_srfi1_partition): delete. * libguile/srfi-1.h (scm_srfi1_partition): delete. * module/srfi/srfi-1.scm: add partition.
Diffstat (limited to 'libguile/srfi-1.c')
-rw-r--r--libguile/srfi-1.c42
1 files changed, 0 insertions, 42 deletions
diff --git a/libguile/srfi-1.c b/libguile/srfi-1.c
index aaa156d3e..e79492f65 100644
--- a/libguile/srfi-1.c
+++ b/libguile/srfi-1.c
@@ -331,48 +331,6 @@ SCM_DEFINE (scm_srfi1_lset_difference_x, "lset-difference!", 2, 0, 1,
}
#undef FUNC_NAME
-SCM_DEFINE (scm_srfi1_partition, "partition", 2, 0, 0,
- (SCM pred, SCM list),
- "Partition the elements of @var{list} with predicate @var{pred}.\n"
- "Return two values: the list of elements satisfying @var{pred} and\n"
- "the list of elements @emph{not} satisfying @var{pred}. The order\n"
- "of the output lists follows the order of @var{list}. @var{list}\n"
- "is not mutated. One of the output lists may share memory with @var{list}.\n")
-#define FUNC_NAME s_scm_srfi1_partition
-{
- /* In this implementation, the output lists don't share memory with
- list, because it's probably not worth the effort. */
- SCM orig_list = list;
- SCM kept = scm_cons(SCM_EOL, SCM_EOL);
- SCM kept_tail = kept;
- SCM dropped = scm_cons(SCM_EOL, SCM_EOL);
- SCM dropped_tail = dropped;
-
- SCM_VALIDATE_PROC (SCM_ARG1, pred);
-
- for (; !SCM_NULL_OR_NIL_P (list); list = SCM_CDR(list)) {
- SCM elt, new_tail;
-
- /* Make sure LIST is not a dotted list. */
- SCM_ASSERT (scm_is_pair (list), orig_list, SCM_ARG2, FUNC_NAME);
-
- elt = SCM_CAR (list);
- new_tail = scm_cons (SCM_CAR (list), SCM_EOL);
-
- if (scm_is_true (scm_call_1 (pred, elt))) {
- SCM_SETCDR(kept_tail, new_tail);
- kept_tail = new_tail;
- }
- else {
- SCM_SETCDR(dropped_tail, new_tail);
- dropped_tail = new_tail;
- }
- }
- return scm_values_2 (SCM_CDR (kept), SCM_CDR (dropped));
-}
-#undef FUNC_NAME
-
-
SCM_DEFINE (scm_srfi1_partition_x, "partition!", 2, 0, 0,
(SCM pred, SCM lst),
"Split @var{lst} into those elements which do and don't satisfy\n"