mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
* alist.c (scm_assq_remove_x, scm_assv_remove_x,
scm_assoc_remove_x): Remove only the first cell with a matching key, not all.
This commit is contained in:
parent
b73bde31c7
commit
623ada63ad
1 changed files with 10 additions and 16 deletions
|
@ -331,18 +331,16 @@ SCM_DEFINE (scm_assq_remove_x, "assq-remove!", 2, 0, 0,
|
||||||
(SCM alist, SCM key),
|
(SCM alist, SCM key),
|
||||||
"@deffnx primitive assv-remove! alist key\n"
|
"@deffnx primitive assv-remove! alist key\n"
|
||||||
"@deffnx primitive assoc-remove! alist key\n"
|
"@deffnx primitive assoc-remove! alist key\n"
|
||||||
"Delete all entries in @var{alist} associated with @var{key}, and return\n"
|
"Delete the first entry in @var{alist} associated with @var{key}, and return\n"
|
||||||
"the resulting alist.")
|
"the resulting alist.")
|
||||||
#define FUNC_NAME s_scm_assq_remove_x
|
#define FUNC_NAME s_scm_assq_remove_x
|
||||||
{
|
{
|
||||||
SCM handle;
|
SCM handle;
|
||||||
|
|
||||||
handle = scm_sloppy_assq (key, alist);
|
handle = scm_sloppy_assq (key, alist);
|
||||||
while (SCM_CONSP (handle))
|
if (SCM_CONSP (handle))
|
||||||
{
|
alist = scm_delq_x (handle, alist);
|
||||||
alist = scm_delq_x (handle, alist);
|
|
||||||
handle = scm_sloppy_assq (key, alist);
|
|
||||||
}
|
|
||||||
return alist;
|
return alist;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
@ -356,11 +354,9 @@ SCM_DEFINE (scm_assv_remove_x, "assv-remove!", 2, 0, 0,
|
||||||
SCM handle;
|
SCM handle;
|
||||||
|
|
||||||
handle = scm_sloppy_assv (key, alist);
|
handle = scm_sloppy_assv (key, alist);
|
||||||
while (SCM_CONSP (handle))
|
if (SCM_CONSP (handle))
|
||||||
{
|
alist = scm_delq_x (handle, alist);
|
||||||
alist = scm_delq_x (handle, alist);
|
|
||||||
handle = scm_sloppy_assv (key, alist);
|
|
||||||
}
|
|
||||||
return alist;
|
return alist;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
@ -374,11 +370,9 @@ SCM_DEFINE (scm_assoc_remove_x, "assoc-remove!", 2, 0, 0,
|
||||||
SCM handle;
|
SCM handle;
|
||||||
|
|
||||||
handle = scm_sloppy_assoc (key, alist);
|
handle = scm_sloppy_assoc (key, alist);
|
||||||
while (SCM_CONSP (handle))
|
if (SCM_CONSP (handle))
|
||||||
{
|
alist = scm_delq_x (handle, alist);
|
||||||
alist = scm_delq_x (handle, alist);
|
|
||||||
handle = scm_sloppy_assoc (key, alist);
|
|
||||||
}
|
|
||||||
return alist;
|
return alist;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue