mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
Use scm_is_pair instead of SCM_CONSP; use scm_is_null instead of
SCM_NULLP.
This commit is contained in:
parent
b4fddbbeda
commit
896df2d58b
1 changed files with 28 additions and 28 deletions
|
@ -39,11 +39,11 @@ srfi1_ilength (SCM sx)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (SCM_NULL_OR_NIL_P(hare)) return i;
|
if (SCM_NULL_OR_NIL_P(hare)) return i;
|
||||||
if (!SCM_CONSP (hare)) return -2;
|
if (!scm_is_pair (hare)) return -2;
|
||||||
hare = SCM_CDR(hare);
|
hare = SCM_CDR(hare);
|
||||||
i++;
|
i++;
|
||||||
if (SCM_NULL_OR_NIL_P(hare)) return i;
|
if (SCM_NULL_OR_NIL_P(hare)) return i;
|
||||||
if (!SCM_CONSP (hare)) return -2;
|
if (!scm_is_pair (hare)) return -2;
|
||||||
hare = SCM_CDR(hare);
|
hare = SCM_CDR(hare);
|
||||||
i++;
|
i++;
|
||||||
/* For every two steps the hare takes, the tortoise takes one. */
|
/* For every two steps the hare takes, the tortoise takes one. */
|
||||||
|
@ -91,21 +91,21 @@ SCM_DEFINE (scm_srfi1_count, "count", 2, 0, 1,
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
if (SCM_NULLP (rest))
|
if (scm_is_null (rest))
|
||||||
{
|
{
|
||||||
/* one list */
|
/* one list */
|
||||||
scm_t_trampoline_1 pred_tramp;
|
scm_t_trampoline_1 pred_tramp;
|
||||||
pred_tramp = scm_trampoline_1 (pred);
|
pred_tramp = scm_trampoline_1 (pred);
|
||||||
SCM_ASSERT (pred_tramp, pred, SCM_ARG1, FUNC_NAME);
|
SCM_ASSERT (pred_tramp, pred, SCM_ARG1, FUNC_NAME);
|
||||||
|
|
||||||
for ( ; SCM_CONSP (list1); list1 = SCM_CDR (list1))
|
for ( ; scm_is_pair (list1); list1 = SCM_CDR (list1))
|
||||||
count += scm_is_true (pred_tramp (pred, SCM_CAR (list1)));
|
count += scm_is_true (pred_tramp (pred, SCM_CAR (list1)));
|
||||||
|
|
||||||
end_lst1:
|
end_lst1:
|
||||||
SCM_ASSERT_TYPE (SCM_NULL_OR_NIL_P (list1), list1, SCM_ARG2, FUNC_NAME,
|
SCM_ASSERT_TYPE (SCM_NULL_OR_NIL_P (list1), list1, SCM_ARG2, FUNC_NAME,
|
||||||
"list");
|
"list");
|
||||||
}
|
}
|
||||||
else if (SCM_CONSP (rest) && SCM_NULLP (SCM_CDR (rest)))
|
else if (scm_is_pair (rest) && scm_is_null (SCM_CDR (rest)))
|
||||||
{
|
{
|
||||||
/* two lists */
|
/* two lists */
|
||||||
scm_t_trampoline_2 pred_tramp;
|
scm_t_trampoline_2 pred_tramp;
|
||||||
|
@ -117,9 +117,9 @@ SCM_DEFINE (scm_srfi1_count, "count", 2, 0, 1,
|
||||||
list2 = SCM_CAR (rest);
|
list2 = SCM_CAR (rest);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (! SCM_CONSP (list1))
|
if (! scm_is_pair (list1))
|
||||||
goto end_lst1;
|
goto end_lst1;
|
||||||
if (! SCM_CONSP (list2))
|
if (! scm_is_pair (list2))
|
||||||
{
|
{
|
||||||
SCM_ASSERT_TYPE (SCM_NULL_OR_NIL_P (list2), list2, SCM_ARG3,
|
SCM_ASSERT_TYPE (SCM_NULL_OR_NIL_P (list2), list2, SCM_ARG3,
|
||||||
FUNC_NAME, "list");
|
FUNC_NAME, "list");
|
||||||
|
@ -143,7 +143,7 @@ SCM_DEFINE (scm_srfi1_count, "count", 2, 0, 1,
|
||||||
/* args is the argument list to pass to pred, same length as lstlst,
|
/* args is the argument list to pass to pred, same length as lstlst,
|
||||||
re-used for each call */
|
re-used for each call */
|
||||||
args = SCM_EOL;
|
args = SCM_EOL;
|
||||||
for (l = lstlst; SCM_CONSP (l); l = SCM_CDR (l))
|
for (l = lstlst; scm_is_pair (l); l = SCM_CDR (l))
|
||||||
args = scm_cons (SCM_BOOL_F, args);
|
args = scm_cons (SCM_BOOL_F, args);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -151,11 +151,11 @@ SCM_DEFINE (scm_srfi1_count, "count", 2, 0, 1,
|
||||||
/* first elem of each list in lstlst into args, and step those
|
/* first elem of each list in lstlst into args, and step those
|
||||||
lstlst entries onto their next element */
|
lstlst entries onto their next element */
|
||||||
for (l = lstlst, a = args, argnum = 2;
|
for (l = lstlst, a = args, argnum = 2;
|
||||||
SCM_CONSP (l);
|
scm_is_pair (l);
|
||||||
l = SCM_CDR (l), a = SCM_CDR (a), argnum++)
|
l = SCM_CDR (l), a = SCM_CDR (a), argnum++)
|
||||||
{
|
{
|
||||||
lst = SCM_CAR (l); /* list argument */
|
lst = SCM_CAR (l); /* list argument */
|
||||||
if (! SCM_CONSP (lst))
|
if (! scm_is_pair (lst))
|
||||||
{
|
{
|
||||||
SCM_ASSERT_TYPE (SCM_NULL_OR_NIL_P (lst), lst,
|
SCM_ASSERT_TYPE (SCM_NULL_OR_NIL_P (lst), lst,
|
||||||
argnum, FUNC_NAME, "list");
|
argnum, FUNC_NAME, "list");
|
||||||
|
@ -216,7 +216,7 @@ SCM_DEFINE (scm_srfi1_delete, "delete", 2, 1, 0,
|
||||||
ret = SCM_EOL;
|
ret = SCM_EOL;
|
||||||
p = &ret;
|
p = &ret;
|
||||||
|
|
||||||
for ( ; SCM_CONSP (lst); lst = SCM_CDR (lst))
|
for ( ; scm_is_pair (lst); lst = SCM_CDR (lst))
|
||||||
{
|
{
|
||||||
if (scm_is_true (equal_p (pred, x, SCM_CAR (lst))))
|
if (scm_is_true (equal_p (pred, x, SCM_CAR (lst))))
|
||||||
{
|
{
|
||||||
|
@ -274,7 +274,7 @@ SCM_DEFINE (scm_srfi1_delete_x, "delete!", 2, 1, 0,
|
||||||
SCM_ASSERT (equal_p, pred, SCM_ARG3, FUNC_NAME);
|
SCM_ASSERT (equal_p, pred, SCM_ARG3, FUNC_NAME);
|
||||||
|
|
||||||
for (prev = &lst, walk = lst;
|
for (prev = &lst, walk = lst;
|
||||||
SCM_CONSP (walk);
|
scm_is_pair (walk);
|
||||||
walk = SCM_CDR (walk))
|
walk = SCM_CDR (walk))
|
||||||
{
|
{
|
||||||
if (scm_is_true (equal_p (pred, x, SCM_CAR (walk))))
|
if (scm_is_true (equal_p (pred, x, SCM_CAR (walk))))
|
||||||
|
@ -338,7 +338,7 @@ SCM_DEFINE (scm_srfi1_delete_duplicates, "delete-duplicates", 1, 1, 0,
|
||||||
|
|
||||||
/* skip to end if an empty list (or something invalid) */
|
/* skip to end if an empty list (or something invalid) */
|
||||||
ret = lst;
|
ret = lst;
|
||||||
if (SCM_CONSP (lst))
|
if (scm_is_pair (lst))
|
||||||
{
|
{
|
||||||
if (SCM_UNBNDP (pred))
|
if (SCM_UNBNDP (pred))
|
||||||
equal_p = equal_trampoline;
|
equal_p = equal_trampoline;
|
||||||
|
@ -355,7 +355,7 @@ SCM_DEFINE (scm_srfi1_delete_duplicates, "delete-duplicates", 1, 1, 0,
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
lst = SCM_CDR (lst);
|
lst = SCM_CDR (lst);
|
||||||
if (! SCM_CONSP (lst))
|
if (! scm_is_pair (lst))
|
||||||
break;
|
break;
|
||||||
item = SCM_CAR (lst);
|
item = SCM_CAR (lst);
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ SCM_DEFINE (scm_srfi1_delete_duplicates_x, "delete-duplicates!", 1, 1, 0,
|
||||||
|
|
||||||
/* skip to end if an empty list (or something invalid) */
|
/* skip to end if an empty list (or something invalid) */
|
||||||
ret = lst;
|
ret = lst;
|
||||||
if (SCM_CONSP (lst))
|
if (scm_is_pair (lst))
|
||||||
{
|
{
|
||||||
if (SCM_UNBNDP (pred))
|
if (SCM_UNBNDP (pred))
|
||||||
equal_p = equal_trampoline;
|
equal_p = equal_trampoline;
|
||||||
|
@ -439,7 +439,7 @@ SCM_DEFINE (scm_srfi1_delete_duplicates_x, "delete-duplicates!", 1, 1, 0,
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
lst = SCM_CDR (lst);
|
lst = SCM_CDR (lst);
|
||||||
if (! SCM_CONSP (lst))
|
if (! scm_is_pair (lst))
|
||||||
break;
|
break;
|
||||||
item = SCM_CAR (lst);
|
item = SCM_CAR (lst);
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ SCM_DEFINE (scm_srfi1_list_copy, "list-copy", 1, 0, 0,
|
||||||
fill_here = &newlst;
|
fill_here = &newlst;
|
||||||
from_here = lst;
|
from_here = lst;
|
||||||
|
|
||||||
while (SCM_CONSP (from_here))
|
while (scm_is_pair (from_here))
|
||||||
{
|
{
|
||||||
SCM c;
|
SCM c;
|
||||||
c = scm_cons (SCM_CAR (from_here), SCM_CDR (from_here));
|
c = scm_cons (SCM_CAR (from_here), SCM_CDR (from_here));
|
||||||
|
@ -538,7 +538,7 @@ check_map_args (SCM argv,
|
||||||
SCM elt = SCM_SIMPLE_VECTOR_REF (argv, i);
|
SCM elt = SCM_SIMPLE_VECTOR_REF (argv, i);
|
||||||
long elt_len;
|
long elt_len;
|
||||||
|
|
||||||
if (!(SCM_NULLP (elt) || SCM_CONSP (elt)))
|
if (!(scm_is_null (elt) || scm_is_pair (elt)))
|
||||||
{
|
{
|
||||||
check_map_error:
|
check_map_error:
|
||||||
if (gf)
|
if (gf)
|
||||||
|
@ -581,11 +581,11 @@ scm_srfi1_map (SCM proc, SCM arg1, SCM args)
|
||||||
SCM *pres = &res;
|
SCM *pres = &res;
|
||||||
|
|
||||||
len = srfi1_ilength (arg1);
|
len = srfi1_ilength (arg1);
|
||||||
SCM_GASSERTn ((SCM_NULLP (arg1) || SCM_CONSP (arg1)) && len >= -1,
|
SCM_GASSERTn ((scm_is_null (arg1) || scm_is_pair (arg1)) && len >= -1,
|
||||||
g_srfi1_map,
|
g_srfi1_map,
|
||||||
scm_cons2 (proc, arg1, args), SCM_ARG2, s_srfi1_map);
|
scm_cons2 (proc, arg1, args), SCM_ARG2, s_srfi1_map);
|
||||||
SCM_VALIDATE_REST_ARGUMENT (args);
|
SCM_VALIDATE_REST_ARGUMENT (args);
|
||||||
if (SCM_NULLP (args))
|
if (scm_is_null (args))
|
||||||
{
|
{
|
||||||
scm_t_trampoline_1 call = scm_trampoline_1 (proc);
|
scm_t_trampoline_1 call = scm_trampoline_1 (proc);
|
||||||
SCM_GASSERT2 (call, g_srfi1_map, proc, arg1, SCM_ARG1, s_srfi1_map);
|
SCM_GASSERT2 (call, g_srfi1_map, proc, arg1, SCM_ARG1, s_srfi1_map);
|
||||||
|
@ -598,7 +598,7 @@ scm_srfi1_map (SCM proc, SCM arg1, SCM args)
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
if (SCM_NULLP (SCM_CDR (args)))
|
if (scm_is_null (SCM_CDR (args)))
|
||||||
{
|
{
|
||||||
SCM arg2 = SCM_CAR (args);
|
SCM arg2 = SCM_CAR (args);
|
||||||
int len2 = srfi1_ilength (arg2);
|
int len2 = srfi1_ilength (arg2);
|
||||||
|
@ -607,7 +607,7 @@ scm_srfi1_map (SCM proc, SCM arg1, SCM args)
|
||||||
scm_cons2 (proc, arg1, args), SCM_ARG1, s_srfi1_map);
|
scm_cons2 (proc, arg1, args), SCM_ARG1, s_srfi1_map);
|
||||||
if (len < 0 || (len2 >= 0 && len2 < len))
|
if (len < 0 || (len2 >= 0 && len2 < len))
|
||||||
len = len2;
|
len = len2;
|
||||||
SCM_GASSERTn ((SCM_NULLP (arg2) || SCM_CONSP (arg2))
|
SCM_GASSERTn ((scm_is_null (arg2) || scm_is_pair (arg2))
|
||||||
&& len >= 0 && len2 >= -1,
|
&& len >= 0 && len2 >= -1,
|
||||||
g_srfi1_map,
|
g_srfi1_map,
|
||||||
scm_cons2 (proc, arg1, args),
|
scm_cons2 (proc, arg1, args),
|
||||||
|
@ -652,11 +652,11 @@ scm_srfi1_for_each (SCM proc, SCM arg1, SCM args)
|
||||||
{
|
{
|
||||||
long i, len;
|
long i, len;
|
||||||
len = srfi1_ilength (arg1);
|
len = srfi1_ilength (arg1);
|
||||||
SCM_GASSERTn ((SCM_NULLP (arg1) || SCM_CONSP (arg1)) && len >= -1,
|
SCM_GASSERTn ((scm_is_null (arg1) || scm_is_pair (arg1)) && len >= -1,
|
||||||
g_srfi1_for_each, scm_cons2 (proc, arg1, args),
|
g_srfi1_for_each, scm_cons2 (proc, arg1, args),
|
||||||
SCM_ARG2, s_srfi1_for_each);
|
SCM_ARG2, s_srfi1_for_each);
|
||||||
SCM_VALIDATE_REST_ARGUMENT (args);
|
SCM_VALIDATE_REST_ARGUMENT (args);
|
||||||
if (SCM_NULLP (args))
|
if (scm_is_null (args))
|
||||||
{
|
{
|
||||||
scm_t_trampoline_1 call = scm_trampoline_1 (proc);
|
scm_t_trampoline_1 call = scm_trampoline_1 (proc);
|
||||||
SCM_GASSERT2 (call, g_srfi1_for_each, proc, arg1,
|
SCM_GASSERT2 (call, g_srfi1_for_each, proc, arg1,
|
||||||
|
@ -670,7 +670,7 @@ scm_srfi1_for_each (SCM proc, SCM arg1, SCM args)
|
||||||
}
|
}
|
||||||
return SCM_UNSPECIFIED;
|
return SCM_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
if (SCM_NULLP (SCM_CDR (args)))
|
if (scm_is_null (SCM_CDR (args)))
|
||||||
{
|
{
|
||||||
SCM arg2 = SCM_CAR (args);
|
SCM arg2 = SCM_CAR (args);
|
||||||
int len2 = srfi1_ilength (arg2);
|
int len2 = srfi1_ilength (arg2);
|
||||||
|
@ -679,7 +679,7 @@ scm_srfi1_for_each (SCM proc, SCM arg1, SCM args)
|
||||||
scm_cons2 (proc, arg1, args), SCM_ARG1, s_srfi1_for_each);
|
scm_cons2 (proc, arg1, args), SCM_ARG1, s_srfi1_for_each);
|
||||||
if (len < 0 || (len2 >= 0 && len2 < len))
|
if (len < 0 || (len2 >= 0 && len2 < len))
|
||||||
len = len2;
|
len = len2;
|
||||||
SCM_GASSERTn ((SCM_NULLP (arg2) || SCM_CONSP (arg2))
|
SCM_GASSERTn ((scm_is_null (arg2) || scm_is_pair (arg2))
|
||||||
&& len >= 0 && len2 >= -1,
|
&& len >= 0 && len2 >= -1,
|
||||||
g_srfi1_for_each,
|
g_srfi1_for_each,
|
||||||
scm_cons2 (proc, arg1, args),
|
scm_cons2 (proc, arg1, args),
|
||||||
|
@ -767,10 +767,10 @@ SCM_DEFINE (scm_srfi1_assoc, "assoc", 2, 1, 0,
|
||||||
equal_p = scm_trampoline_2 (pred);
|
equal_p = scm_trampoline_2 (pred);
|
||||||
SCM_ASSERT (equal_p, pred, 3, FUNC_NAME);
|
SCM_ASSERT (equal_p, pred, 3, FUNC_NAME);
|
||||||
}
|
}
|
||||||
for(; SCM_CONSP (ls); ls = SCM_CDR (ls))
|
for(; scm_is_pair (ls); ls = SCM_CDR (ls))
|
||||||
{
|
{
|
||||||
SCM tmp = SCM_CAR (ls);
|
SCM tmp = SCM_CAR (ls);
|
||||||
SCM_ASSERT_TYPE (SCM_CONSP (tmp), alist, SCM_ARG2, FUNC_NAME,
|
SCM_ASSERT_TYPE (scm_is_pair (tmp), alist, SCM_ARG2, FUNC_NAME,
|
||||||
"association list");
|
"association list");
|
||||||
if (scm_is_true (equal_p (pred, SCM_CAR (tmp), key)))
|
if (scm_is_true (equal_p (pred, SCM_CAR (tmp), key)))
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue