1996-07-25 22:56:11 +00:00
|
|
|
|
/* Copyright (C) 1995,1996 Free Software Foundation, Inc.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
|
* any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this software; see the file COPYING. If not, write to
|
|
|
|
|
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
*
|
|
|
|
|
|
* As a special exception, the Free Software Foundation gives permission
|
|
|
|
|
|
* for additional uses of the text contained in its release of GUILE.
|
|
|
|
|
|
*
|
|
|
|
|
|
* The exception is that, if you link the GUILE library with other files
|
|
|
|
|
|
* to produce an executable, this does not by itself cause the
|
|
|
|
|
|
* resulting executable to be covered by the GNU General Public License.
|
|
|
|
|
|
* Your use of that executable is in no way restricted on account of
|
|
|
|
|
|
* linking the GUILE library code into it.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This exception does not however invalidate any other reasons why
|
|
|
|
|
|
* the executable file might be covered by the GNU General Public License.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This exception applies only to the code released by the
|
|
|
|
|
|
* Free Software Foundation under the name GUILE. If you copy
|
|
|
|
|
|
* code from other Free Software Foundation releases into a copy of
|
|
|
|
|
|
* GUILE, as the General Public License permits, the exception does
|
|
|
|
|
|
* not apply to the code that you add in this way. To avoid misleading
|
|
|
|
|
|
* anyone as to the status of such modified files, you must delete
|
|
|
|
|
|
* this exception notice from them.
|
|
|
|
|
|
*
|
|
|
|
|
|
* If you write modifications of your own for GUILE, it is your choice
|
|
|
|
|
|
* whether to permit this exception to apply to your modifications.
|
|
|
|
|
|
* If you do not wish that, delete this exception notice.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#include "_scm.h"
|
C files should #include only the header files they need, not
libguile.h (which #includes all the header files); the pointless
recompilation was wasting my time.
* Makefile.in (all .o dependency lists): Regenerated.
* libguile.h: Don't try to get a definition for size_t here...
* __scm.h: Do it here.
* _scm.h: Since this is the internal libguile header, put things
here that all (or a majority) of the libguile files will want.
Don't #include <libguile.h> here; that generates dependencies on
way too much. Instead, get "__scm.h", "error.h", "pairs.h",
"list.h", "gc.h", "gsubr.h", "procs.h", "numbers.h", "symbols.h",
"boolean.h", "strings.h", "vectors.h", "root.h", "ports.h", and
"async.h".
* alist.c: Get "eq.h", "list.h", "alist.h".
* append.c: Get "append.h", "list.h".
* arbiters.c: Get "arbiters.h", "smob.h".
* async.c: Get "async.h", "smob.h", "throw.h", "eval.h".
* boolean.c: Get "boolean.h".
* chars.c: Get "chars.h".
* continuations.c: Get "continuations.h", "dynwind.h", "debug.h",
"stackchk.h".
* debug.c: Get "debug.h", "feature.h", "read.h", "strports.h",
"continuations.h", "alist.h", "srcprop.h", "procprop.h", "smob.h",
"genio.h", "throw.h", "eval.h".
* dynwind.c: Get "dynwind.h", "alist.h", "eval.h".
* eq.c: Get "eq.h", "unif.h", "smob.h", "strorder.h",
"stackchk.h".
* error.c: Get "error.h", "throw.h", "genio.h", "pairs.h".
* eval.c: Get "eval.h", "stackchk.h", "srcprop.h", "debug.h",
"hashtab.h", "procprop.h", "markers.h", "smob.h", "throw.h",
"continuations.h", "eq.h", "sequences.h", "alist.h", "append.h",
"debug.h".
* fdsocket.c: Get "fdsocket.h", "unif.h", "filesys.h".
* feature.c: Get "feature.h".
* files.c: Get "files.h".
* filesys.c: Get "filesys.h", "smob.h", "genio.h".
* fports.c: Get "fports.h", "markers.h".
* gc.c: Get "async.h", "unif.h", "smob.h", "weaks.h",
"genio.h", "struct.h", "stackchk.h", "stime.h".
* gdbint.c: Get "gdbint.h", "chars.h", "eval.h", "print.h",
"read.h", "strports.h", "tag.h".
* genio.c: Get "genio.h", "chars.h".
* gsubr.c: Get "gsubr.h", "genio.h".
* hash.c: Get "hash.h", "chars.h".
* hashtab.c: Get "hashtab.h", "eval.h", "hash.h", "alist.h".
* init.c: Get everyone who has an scm_init_mumble function:
"weaks.h", "vports.h", "version.h", "vectors.h", "variable.h",
"unif.h", "throw.h", "tag.h", "symbols.h", "struct.h",
"strports.h", "strorder.h", "strop.h", "strings.h", "stime.h",
"stackchk.h", "srcprop.h", "socket.h", "simpos.h", "sequences.h",
"scmsigs.h", "read.h", "ramap.h", "procs.h", "procprop.h",
"print.h", "posix.h", "ports.h", "pairs.h", "options.h",
"objprop.h", "numbers.h", "mbstrings.h", "mallocs.h", "load.h",
"list.h", "kw.h", "ioext.h", "hashtab.h", "hash.h", "gsubr.h",
"gdbint.h", "gc.h", "fports.h", "filesys.h", "files.h",
"feature.h", "fdsocket.h", "eval.h", "error.h", "eq.h",
"dynwind.h", "debug.h", "continuations.h", "chars.h", "boolean.h",
"async.h", "arbiters.h", "append.h", "alist.h".
* ioext.c: Get "ioext.h", "fports.h".
* kw.c: Get "kw.h", "smob.h", "mbstrings.h", "genio.h".
* list.c: Get "list.h", "eq.h".
* load.c: Get "load.h", "eval.h", "read.h", "fports.h".
* mallocs.c: Get "smob.h", "genio.h".
* markers.c: Get "markers.h".
* mbstrings.c: Get "mbstrings.h", "read.h", "genio.h", "unif.h",
"chars.h".
* numbers.c: Get "unif.h", "genio.h".
* objprop.c: Get "objprop.h", "weaks.h", "alist.h", "hashtab.h".
* options.c: Get "options.h".
* ports.c: Get "ports.h", "vports.h", "strports.h", "fports.h",
"markers.h", "chars.h", "genio.h".
* posix.c: Get "posix.h", "sequences.h", "feature.h", "unif.h",
"read.h", "scmsigs.h", "genio.h", "fports.h".
* print.c: Get "print.h", "unif.h", "weaks.h", "read.h",
"procprop.h", "eval.h", "smob.h", "mbstrings.h", "genio.h",
"chars.h".
* procprop.c: Get "procprop.h", "eval.h", "alist.h".
* procs.c: Get "procs.h".
* ramap.c: Get "ramap.h", "feature.h", "eval.h", "eq.h",
"chars.h", "smob.h", "unif.h".
* read.c: Get "alist.h", "kw.h", "mbstrings.h", "unif.h",
"eval.h", "genio.h", "chars.h".
* root.c: Get "root.h", "stackchk.h".
* scmsigs.c: Get "scmsigs.h".
* sequences.c: Get "sequences.h".
* simpos.c: Get "simpos.h", "scmsigs.h".
* smob.c: Get "smob.h".
* socket.c: Get "socket.h", "feature.h".
* srcprop.c: Get "srcprop.h", "weaks.h", "hashtab.h", "debug.h",
"alist.h", "smob.h".
* stackchk.c: Get "stackchk.h", "genio.h".
* stime.c: Get "stime.h"."libguile/continuations.h".
* strings.c: Get "strings.h", "chars.h".
* strop.c: Get "strop.h", "chars.h".
* strorder.c: Get "strorder.h", "chars.h".
* strports.c: Get "strports.h", "print.h", "eval.h", "unif.h".
* struct.c: Get "struct.h", "chars.h".
* symbols.c: Get "symbols.h", "mbstrings.h", "alist.h",
"variable.h", "eval.h", "chars.h".
* tag.c: Get "tag.h", "struct.h", "chars.h".
* throw.c: Get "throw.h", "continuations.h", "debug.h",
"dynwind.h", "eval.h", "alist.h", "smob.h", "genio.h".
* unif.c: Get "unif.h", "feature.h", "strop.h", "sequences.h",
"smob.h", "genio.h", "eval.h", "chars.h".
* variable.c: Get "variable.h", "smob.h", "genio.h".
* vectors.c: Get "vectors.h", "eq.h".
* version.c: Get "version.h".
* vports.c: Get "vports.h", "fports.h", "chars.h", "eval.h".
* weaks.c: Get "weaks.h".
1996-09-10 02:26:07 +00:00
|
|
|
|
#include "eq.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "list.h"
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
#ifdef __STDC__
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
#define var_start(x, y) va_start(x, y)
|
|
|
|
|
|
#else
|
|
|
|
|
|
#include <varargs.h>
|
|
|
|
|
|
#define var_start(x, y) va_start(x)
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* creating lists */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* SCM_P won't help us deal with varargs here. */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#ifdef __STDC__
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_listify (SCM elt, ...)
|
|
|
|
|
|
#else
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_listify (elt, va_alist)
|
|
|
|
|
|
SCM elt;
|
|
|
|
|
|
va_dcl
|
|
|
|
|
|
#endif
|
|
|
|
|
|
{
|
|
|
|
|
|
va_list foo;
|
|
|
|
|
|
SCM answer;
|
|
|
|
|
|
SCM *pos;
|
|
|
|
|
|
|
|
|
|
|
|
var_start (foo, elt);
|
|
|
|
|
|
answer = SCM_EOL;
|
|
|
|
|
|
pos = &answer;
|
|
|
|
|
|
while (elt != SCM_UNDEFINED)
|
|
|
|
|
|
{
|
|
|
|
|
|
*pos = scm_cons (elt, SCM_EOL);
|
* pairs.h, eval.c, eval.h, feature.c, gc.c, list.c, load.c,
ramap.c, symbols.c: Added new selectors SCM_CARLOC and SCM_CDRLOC
for obtaining the address of a car or cdr field. Motivation:
&SCM_CXR make assumptions about the internal structure of the
SCM_CXR selectors.
* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
1996-10-20 03:29:38 +00:00
|
|
|
|
pos = SCM_CDRLOC (*pos);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
elt = va_arg (foo, SCM);
|
|
|
|
|
|
}
|
|
|
|
|
|
return answer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_list, "list", 0, 0, 1, scm_list);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list(objs)
|
|
|
|
|
|
SCM objs;
|
|
|
|
|
|
{
|
|
|
|
|
|
return objs;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* general questions about lists --- null?, list?, length, etc. */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_null_p, "null?", 1, 0, 0, scm_null_p);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_null_p(x)
|
|
|
|
|
|
SCM x;
|
|
|
|
|
|
{
|
|
|
|
|
|
return SCM_NULLP(x) ? SCM_BOOL_T : SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_list_p, "list?", 1, 0, 0, scm_list_p);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_p(x)
|
|
|
|
|
|
SCM x;
|
|
|
|
|
|
{
|
|
|
|
|
|
if (scm_ilength(x)<0)
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
else
|
|
|
|
|
|
return SCM_BOOL_T;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* Return the length of SX, or -1 if it's not a proper list.
|
|
|
|
|
|
This uses the "tortise and hare" algorithm to detect "infinitely
|
|
|
|
|
|
long" lists (i.e. lists with cycles in their cdrs), and returns -1
|
|
|
|
|
|
if it does find one. */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
long
|
|
|
|
|
|
scm_ilength(sx)
|
|
|
|
|
|
SCM sx;
|
|
|
|
|
|
{
|
|
|
|
|
|
register long i = 0;
|
1996-10-03 05:17:17 +00:00
|
|
|
|
register SCM tortise = sx;
|
|
|
|
|
|
register SCM hare = sx;
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
do {
|
1996-10-03 05:17:17 +00:00
|
|
|
|
if SCM_IMP(hare) return SCM_NULLP(hare) ? i : -1;
|
|
|
|
|
|
if SCM_NCONSP(hare) return -1;
|
|
|
|
|
|
hare = SCM_CDR(hare);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
i++;
|
1996-10-03 05:17:17 +00:00
|
|
|
|
if SCM_IMP(hare) return SCM_NULLP(hare) ? i : -1;
|
|
|
|
|
|
if SCM_NCONSP(hare) return -1;
|
|
|
|
|
|
hare = SCM_CDR(hare);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
i++;
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* For every two steps the hare takes, the tortise takes one. */
|
|
|
|
|
|
tortise = SCM_CDR(tortise);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1996-10-03 05:17:17 +00:00
|
|
|
|
while (hare != tortise);
|
|
|
|
|
|
|
|
|
|
|
|
/* If the tortise ever catches the hare, then the list must contain
|
|
|
|
|
|
a cycle. */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_list_length, "list-length", 1, 0, 0, scm_list_length);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_length(x)
|
|
|
|
|
|
SCM x;
|
|
|
|
|
|
{
|
|
|
|
|
|
int i;
|
|
|
|
|
|
i = scm_ilength(x);
|
|
|
|
|
|
SCM_ASSERT(i >= 0, x, SCM_ARG1, s_list_length);
|
|
|
|
|
|
return SCM_MAKINUM (i);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* appending lists */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_list_append, "list-append", 0, 0, 1, scm_list_append);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_append(args)
|
|
|
|
|
|
SCM args;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM res = SCM_EOL;
|
|
|
|
|
|
SCM *lloc = &res, arg;
|
|
|
|
|
|
if SCM_IMP(args) {
|
|
|
|
|
|
SCM_ASSERT(SCM_NULLP(args), args, SCM_ARGn, s_list_append);
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
SCM_ASSERT(SCM_CONSP(args), args, SCM_ARGn, s_list_append);
|
|
|
|
|
|
while (1) {
|
|
|
|
|
|
arg = SCM_CAR(args);
|
|
|
|
|
|
args = SCM_CDR(args);
|
|
|
|
|
|
if SCM_IMP(args) {
|
|
|
|
|
|
*lloc = arg;
|
|
|
|
|
|
SCM_ASSERT(SCM_NULLP(args), args, SCM_ARGn, s_list_append);
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
SCM_ASSERT(SCM_CONSP(args), args, SCM_ARGn, s_list_append);
|
|
|
|
|
|
for(;SCM_NIMP(arg);arg = SCM_CDR(arg)) {
|
|
|
|
|
|
SCM_ASSERT(SCM_CONSP(arg), arg, SCM_ARGn, s_list_append);
|
|
|
|
|
|
*lloc = scm_cons(SCM_CAR(arg), SCM_EOL);
|
* pairs.h, eval.c, eval.h, feature.c, gc.c, list.c, load.c,
ramap.c, symbols.c: Added new selectors SCM_CARLOC and SCM_CDRLOC
for obtaining the address of a car or cdr field. Motivation:
&SCM_CXR make assumptions about the internal structure of the
SCM_CXR selectors.
* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
1996-10-20 03:29:38 +00:00
|
|
|
|
lloc = SCM_CDRLOC(*lloc);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
SCM_ASSERT(SCM_NULLP(arg), arg, SCM_ARGn, s_list_append);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_list_append_x, "list-append!", 0, 0, 1, scm_list_append_x);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_append_x(args)
|
|
|
|
|
|
SCM args;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM arg;
|
|
|
|
|
|
tail:
|
|
|
|
|
|
if SCM_NULLP(args) return SCM_EOL;
|
|
|
|
|
|
arg = SCM_CAR(args);
|
|
|
|
|
|
SCM_ASSERT(SCM_NULLP(arg) || (SCM_NIMP(arg) && SCM_CONSP(arg)), arg, SCM_ARG1, s_list_append_x);
|
|
|
|
|
|
args = SCM_CDR(args);
|
|
|
|
|
|
if SCM_NULLP(args) return arg;
|
|
|
|
|
|
if SCM_NULLP(arg) goto tail;
|
* pairs.h, eval.c, eval.h, feature.c, gc.c, list.c, load.c,
ramap.c, symbols.c: Added new selectors SCM_CARLOC and SCM_CDRLOC
for obtaining the address of a car or cdr field. Motivation:
&SCM_CXR make assumptions about the internal structure of the
SCM_CXR selectors.
* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
1996-10-20 03:29:38 +00:00
|
|
|
|
SCM_SETCDR (scm_last_pair (arg), scm_list_append_x (args));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return arg;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
SCM_PROC(s_last_pair, "last-pair", 1, 0, 0, scm_last_pair);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_last_pair(sx)
|
|
|
|
|
|
SCM sx;
|
|
|
|
|
|
{
|
|
|
|
|
|
register SCM res = sx;
|
|
|
|
|
|
register SCM x;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
if (SCM_NULLP (sx))
|
|
|
|
|
|
return SCM_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
SCM_ASSERT(SCM_NIMP(res) && SCM_CONSP(res), res, SCM_ARG1, s_last_pair);
|
|
|
|
|
|
while (!0) {
|
|
|
|
|
|
x = SCM_CDR(res);
|
|
|
|
|
|
if (SCM_IMP(x) || SCM_NCONSP(x)) return res;
|
|
|
|
|
|
res = x;
|
|
|
|
|
|
x = SCM_CDR(res);
|
|
|
|
|
|
if (SCM_IMP(x) || SCM_NCONSP(x)) return res;
|
|
|
|
|
|
res = x;
|
|
|
|
|
|
sx = SCM_CDR(sx);
|
|
|
|
|
|
SCM_ASSERT(x != sx, sx, SCM_ARG1, s_last_pair);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* reversing lists */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_list_reverse, "list-reverse", 1, 0, 0, scm_list_reverse);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_reverse(lst)
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM res = SCM_EOL;
|
|
|
|
|
|
SCM p = lst;
|
|
|
|
|
|
for(;SCM_NIMP(p);p = SCM_CDR(p)) {
|
|
|
|
|
|
SCM_ASSERT(SCM_CONSP(p), lst, SCM_ARG1, s_list_reverse);
|
|
|
|
|
|
res = scm_cons(SCM_CAR(p), res);
|
|
|
|
|
|
}
|
|
|
|
|
|
SCM_ASSERT(SCM_NULLP(p), lst, SCM_ARG1, s_list_reverse);
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_list_reverse_x, "list-reverse!", 1, 1, 0, scm_list_reverse_x);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_reverse_x (lst, newtail)
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
SCM newtail;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM old_tail;
|
|
|
|
|
|
if (newtail == SCM_UNDEFINED)
|
|
|
|
|
|
newtail = SCM_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
loop:
|
|
|
|
|
|
if (!(SCM_NIMP (lst) && SCM_CONSP (lst)))
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
|
|
|
|
|
|
old_tail = SCM_CDR (lst);
|
|
|
|
|
|
SCM_SETCDR (lst, newtail);
|
|
|
|
|
|
if (SCM_NULLP (old_tail))
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
|
|
|
|
|
|
newtail = lst;
|
|
|
|
|
|
lst = old_tail;
|
|
|
|
|
|
goto loop;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* indexing lists by element number */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_list_ref, "list-ref", 2, 0, 0, scm_list_ref);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_ref(lst, k)
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
SCM k;
|
|
|
|
|
|
{
|
|
|
|
|
|
register long i;
|
|
|
|
|
|
SCM_ASSERT(SCM_INUMP(k), k, SCM_ARG2, s_list_ref);
|
|
|
|
|
|
i = SCM_INUM(k);
|
|
|
|
|
|
SCM_ASSERT(i >= 0, k, SCM_ARG2, s_list_ref);
|
|
|
|
|
|
while (i-- > 0) {
|
|
|
|
|
|
SCM_ASRTGO(SCM_NIMP(lst) && SCM_CONSP(lst), erout);
|
|
|
|
|
|
lst = SCM_CDR(lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
erout: SCM_ASSERT(SCM_NIMP(lst) && SCM_CONSP(lst),
|
|
|
|
|
|
SCM_NULLP(lst)?k:lst, SCM_NULLP(lst)?SCM_OUTOFRANGE:SCM_ARG1, s_list_ref);
|
|
|
|
|
|
return SCM_CAR(lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_list_set_x, "list-set!", 3, 0, 0, scm_list_set_x);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_set_x(lst, k, val)
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
SCM k;
|
|
|
|
|
|
SCM val;
|
|
|
|
|
|
{
|
|
|
|
|
|
register long i;
|
|
|
|
|
|
SCM_ASSERT(SCM_INUMP(k), k, SCM_ARG2, s_list_set_x);
|
|
|
|
|
|
i = SCM_INUM(k);
|
|
|
|
|
|
SCM_ASSERT(i >= 0, k, SCM_ARG2, s_list_set_x);
|
|
|
|
|
|
while (i-- > 0) {
|
|
|
|
|
|
SCM_ASRTGO(SCM_NIMP(lst) && SCM_CONSP(lst), erout);
|
|
|
|
|
|
lst = SCM_CDR(lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
erout: SCM_ASSERT(SCM_NIMP(lst) && SCM_CONSP(lst),
|
|
|
|
|
|
SCM_NULLP(lst)?k:lst, SCM_NULLP(lst)?SCM_OUTOFRANGE:SCM_ARG1, s_list_set_x);
|
* pairs.h, eval.c, eval.h, feature.c, gc.c, list.c, load.c,
ramap.c, symbols.c: Added new selectors SCM_CARLOC and SCM_CDRLOC
for obtaining the address of a car or cdr field. Motivation:
&SCM_CXR make assumptions about the internal structure of the
SCM_CXR selectors.
* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
1996-10-20 03:29:38 +00:00
|
|
|
|
SCM_SETCAR (lst, val);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return val;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
SCM_PROC(s_list_cdr_ref, "list-cdr-ref", 2, 0, 0, scm_list_tail);
|
|
|
|
|
|
SCM_PROC(s_list_tail, "list-tail", 2, 0, 0, scm_list_tail);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_tail(lst, k)
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
SCM k;
|
|
|
|
|
|
{
|
|
|
|
|
|
register long i;
|
|
|
|
|
|
SCM_ASSERT(SCM_INUMP(k), k, SCM_ARG2, s_list_tail);
|
|
|
|
|
|
i = SCM_INUM(k);
|
|
|
|
|
|
while (i-- > 0) {
|
|
|
|
|
|
SCM_ASSERT(SCM_NIMP(lst) && SCM_CONSP(lst), lst, SCM_ARG1, s_list_tail);
|
|
|
|
|
|
lst = SCM_CDR(lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_list_cdr_set_x, "list-cdr-set!", 3, 0, 0, scm_list_cdr_set_x);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_cdr_set_x(lst, k, val)
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
SCM k;
|
|
|
|
|
|
SCM val;
|
|
|
|
|
|
{
|
|
|
|
|
|
register long i;
|
|
|
|
|
|
SCM_ASSERT(SCM_INUMP(k), k, SCM_ARG2, s_list_cdr_set_x);
|
|
|
|
|
|
i = SCM_INUM(k);
|
|
|
|
|
|
SCM_ASSERT(i >= 0, k, SCM_ARG2, s_list_cdr_set_x);
|
|
|
|
|
|
while (i-- > 0) {
|
|
|
|
|
|
SCM_ASRTGO(SCM_NIMP(lst) && SCM_CONSP(lst), erout);
|
|
|
|
|
|
lst = SCM_CDR(lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
erout: SCM_ASSERT(SCM_NIMP(lst) && SCM_CONSP(lst),
|
|
|
|
|
|
SCM_NULLP(lst)?k:lst, SCM_NULLP(lst)?SCM_OUTOFRANGE:SCM_ARG1, s_list_cdr_set_x);
|
|
|
|
|
|
SCM_SETCDR (lst, val);
|
|
|
|
|
|
return val;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* copying lists, perhaps partially */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_list_head, "list-head", 2, 0, 0, scm_list_head);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_head(lst, k)
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
SCM k;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM answer;
|
|
|
|
|
|
SCM * pos;
|
|
|
|
|
|
register long i;
|
|
|
|
|
|
|
|
|
|
|
|
SCM_ASSERT(SCM_INUMP(k), k, SCM_ARG2, s_list_head);
|
|
|
|
|
|
answer = SCM_EOL;
|
|
|
|
|
|
pos = &answer;
|
|
|
|
|
|
i = SCM_INUM(k);
|
|
|
|
|
|
while (i-- > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_ASSERT(SCM_NIMP(lst) && SCM_CONSP(lst), lst, SCM_ARG1, s_list_head);
|
|
|
|
|
|
*pos = scm_cons (SCM_CAR (lst), SCM_EOL);
|
* pairs.h, eval.c, eval.h, feature.c, gc.c, list.c, load.c,
ramap.c, symbols.c: Added new selectors SCM_CARLOC and SCM_CDRLOC
for obtaining the address of a car or cdr field. Motivation:
&SCM_CXR make assumptions about the internal structure of the
SCM_CXR selectors.
* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
1996-10-20 03:29:38 +00:00
|
|
|
|
pos = SCM_CDRLOC (*pos);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
lst = SCM_CDR(lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
return answer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
SCM_PROC (s_list_copy, "list-copy", 1, 0, 0, scm_list_copy);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_list_copy (lst)
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM newlst;
|
|
|
|
|
|
SCM * fill_here;
|
|
|
|
|
|
SCM from_here;
|
|
|
|
|
|
|
|
|
|
|
|
newlst = SCM_EOL;
|
|
|
|
|
|
fill_here = &newlst;
|
|
|
|
|
|
from_here = lst;
|
|
|
|
|
|
|
|
|
|
|
|
while (SCM_NIMP (from_here) && SCM_CONSP (from_here))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM c;
|
|
|
|
|
|
c = scm_cons (SCM_CAR (from_here), SCM_CDR (from_here));
|
|
|
|
|
|
*fill_here = c;
|
* pairs.h, eval.c, eval.h, feature.c, gc.c, list.c, load.c,
ramap.c, symbols.c: Added new selectors SCM_CARLOC and SCM_CDRLOC
for obtaining the address of a car or cdr field. Motivation:
&SCM_CXR make assumptions about the internal structure of the
SCM_CXR selectors.
* alist.c, arbiters.c, continuations.c, debug.c, debug.h, eval.c,
eval.h, feature.c, filesys.c, fports.c, gc.c, gsubr.c, init.c,
ioext.c, kw.c, list.c, load.c, mallocs.c, numbers.c, numbers.h,
pairs.c, pairs.h, ports.c, ports.h, posix.c, procprop.c, procs.c,
procs.h, ramap.c, read.c, root.c, srcprop.c, srcprop.h,
strports.c, symbols.c, tags.h, throw.c, unif.c, variable.c,
vports.c: Cleaned up use of pairs: Don't make any special
assumptions about the internal structure of selectors and
mutators: SCM_CXR (<e1>) = <e2> --> SCM_SETCXR (<e1>, <e2>),
SCM_CXR (<e1>) &= <e2> --> SCM_SETAND_CXR (<e1>, <e2>) etc.
(Among other things, this change makes it easier to build Guile
with certain compilers which have problems with casted lvalues.)
1996-10-20 03:29:38 +00:00
|
|
|
|
fill_here = SCM_CDRLOC (c);
|
1996-10-03 05:17:17 +00:00
|
|
|
|
from_here = SCM_CDR (from_here);
|
|
|
|
|
|
}
|
|
|
|
|
|
return newlst;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* membership tests (memq, memv, etc.) */
|
|
|
|
|
|
|
|
|
|
|
|
static void sloppy_mem_check SCM_P ((SCM obj, char * where, char * why));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
|
sloppy_mem_check (obj, where, why)
|
|
|
|
|
|
SCM obj;
|
|
|
|
|
|
char * where;
|
|
|
|
|
|
char * why;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_ASSERT ((scm_ilength (obj) >= 0), obj, where, why);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_sloppy_memq, "sloppy-memq", 2, 0, 0, scm_sloppy_memq);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_sloppy_memq(x, lst)
|
|
|
|
|
|
SCM x;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
for(; SCM_NIMP(lst) && SCM_CONSP (lst); lst = SCM_CDR(lst))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_CAR(lst)==x)
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_sloppy_memv, "sloppy-memv", 2, 0, 0, scm_sloppy_memv);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_sloppy_memv(x, lst)
|
|
|
|
|
|
SCM x;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
for(; SCM_NIMP(lst) && SCM_CONSP (lst); lst = SCM_CDR(lst))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_BOOL_F != scm_eqv_p (SCM_CAR(lst), x))
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_sloppy_member, "sloppy-member", 2, 0, 0, scm_sloppy_member);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_sloppy_member (x, lst)
|
|
|
|
|
|
SCM x;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
for(; SCM_NIMP(lst) && SCM_CONSP (lst); lst = SCM_CDR(lst))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_BOOL_F != scm_equal_p (SCM_CAR(lst), x))
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_memq, "memq", 2, 0, 0, scm_memq);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_memq(x, lst)
|
|
|
|
|
|
SCM x;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM answer;
|
|
|
|
|
|
answer = scm_sloppy_memq (x, lst);
|
|
|
|
|
|
sloppy_mem_check (answer, (char *)SCM_ARG2, s_memq);
|
1996-10-03 05:17:17 +00:00
|
|
|
|
return (answer == SCM_EOL) ? SCM_BOOL_F : answer;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_memv, "memv", 2, 0, 0, scm_memv);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_memv(x, lst)
|
|
|
|
|
|
SCM x;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM answer;
|
|
|
|
|
|
answer = scm_sloppy_memv (x, lst);
|
|
|
|
|
|
sloppy_mem_check (answer, (char *)SCM_ARG2, s_memv);
|
1996-10-03 05:17:17 +00:00
|
|
|
|
return (answer == SCM_EOL) ? SCM_BOOL_F : answer;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_member, "member", 2, 0, 0, scm_member);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_member(x, lst)
|
|
|
|
|
|
SCM x;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM answer;
|
|
|
|
|
|
answer = scm_sloppy_member (x, lst);
|
|
|
|
|
|
sloppy_mem_check (answer, (char *)SCM_ARG2, s_member);
|
1996-10-03 05:17:17 +00:00
|
|
|
|
return (answer == SCM_EOL) ? SCM_BOOL_F : answer;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* deleting elements from a list (delq, etc.) */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_delq_x, "delq!", 2, 0, 0, scm_delq_x);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_delq_x (item, lst)
|
|
|
|
|
|
SCM item;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM start;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_IMP (lst) || SCM_NCONSP (lst))
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_CAR (lst) == item)
|
|
|
|
|
|
return SCM_CDR (lst);
|
|
|
|
|
|
|
|
|
|
|
|
start = lst;
|
|
|
|
|
|
|
|
|
|
|
|
while (SCM_NIMP (SCM_CDR (lst)) && SCM_CONSP (SCM_CDR (lst)))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_CAR (SCM_CDR (lst)) == item)
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_SETCDR (lst, SCM_CDR (SCM_CDR (lst)));
|
|
|
|
|
|
return start;
|
|
|
|
|
|
}
|
|
|
|
|
|
lst = SCM_CDR (lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
return start;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_delv_x, "delv!", 2, 0, 0, scm_delv_x);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_delv_x (item, lst)
|
|
|
|
|
|
SCM item;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM start;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_IMP (lst) || SCM_NCONSP (lst))
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_BOOL_F != scm_eqv_p (SCM_CAR (lst), item))
|
|
|
|
|
|
return SCM_CDR (lst);
|
|
|
|
|
|
|
|
|
|
|
|
start = lst;
|
|
|
|
|
|
|
|
|
|
|
|
while (SCM_NIMP (SCM_CDR (lst)) && SCM_CONSP (SCM_CDR (lst)))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_BOOL_F != scm_eqv_p (SCM_CAR (SCM_CDR (lst)), item))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_SETCDR (lst, SCM_CDR (SCM_CDR (lst)));
|
|
|
|
|
|
return start;
|
|
|
|
|
|
}
|
|
|
|
|
|
lst = SCM_CDR (lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
return start;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC(s_delete_x, "delete!", 2, 0, 0, scm_delete_x);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_delete_x (item, lst)
|
|
|
|
|
|
SCM item;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM start;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_IMP (lst) || SCM_NCONSP (lst))
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
|
|
|
|
|
|
if (SCM_BOOL_F != scm_equal_p (SCM_CAR (lst), item))
|
|
|
|
|
|
return SCM_CDR (lst);
|
|
|
|
|
|
|
|
|
|
|
|
start = lst;
|
|
|
|
|
|
|
|
|
|
|
|
while (SCM_NIMP (SCM_CDR (lst)) && SCM_CONSP (SCM_CDR (lst)))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_BOOL_F != scm_equal_p (SCM_CAR (SCM_CDR (lst)), item))
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM_SETCDR (lst, SCM_CDR (SCM_CDR (lst)));
|
|
|
|
|
|
return start;
|
|
|
|
|
|
}
|
|
|
|
|
|
lst = SCM_CDR (lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
return start;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_delq, "delq", 2, 0, 0, scm_delq);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_delq (item, lst)
|
|
|
|
|
|
SCM item;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM copy;
|
|
|
|
|
|
|
|
|
|
|
|
copy = scm_list_copy (lst);
|
|
|
|
|
|
return scm_delq_x (item, copy);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_delv, "delv", 2, 0, 0, scm_delv);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_delv (item, lst)
|
|
|
|
|
|
SCM item;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM copy;
|
|
|
|
|
|
|
|
|
|
|
|
copy = scm_list_copy (lst);
|
|
|
|
|
|
return scm_delv_x (item, copy);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCM_PROC (s_delete, "delete", 2, 0, 0, scm_delete);
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_delete (item, lst)
|
|
|
|
|
|
SCM item;
|
|
|
|
|
|
SCM lst;
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM copy;
|
|
|
|
|
|
|
|
|
|
|
|
copy = scm_list_copy (lst);
|
|
|
|
|
|
return scm_delete_x (item, copy);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_init_list ()
|
|
|
|
|
|
{
|
|
|
|
|
|
#include "list.x"
|
|
|
|
|
|
}
|