2000-06-12 12:28:24 +00:00
|
|
|
|
/* Copyright (C) 1995,1996,1997, 2000 Free Software Foundation, Inc.
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
|
|
|
|
|
* 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
|
1997-05-26 22:34:48 +00:00
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
|
|
|
|
* Boston, MA 02111-1307 USA
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
|
|
|
|
|
* 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.
|
1997-05-26 22:34:48 +00:00
|
|
|
|
* If you do not wish that, delete this exception notice. */
|
1999-12-12 02:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
|
|
|
|
|
|
gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/_scm.h"
|
|
|
|
|
|
#include "libguile/eq.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
|
|
|
|
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/validate.h"
|
|
|
|
|
|
#include "libguile/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
|
|
|
|
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_listify (SCM elt, ...)
|
|
|
|
|
|
{
|
|
|
|
|
|
va_list foo;
|
2000-01-20 20:59:33 +00:00
|
|
|
|
SCM answer = SCM_EOL;
|
|
|
|
|
|
SCM *pos = &answer;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
var_start (foo, elt);
|
2000-03-29 16:22:57 +00:00
|
|
|
|
while (! SCM_UNBNDP (elt))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
*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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_list, "list", 0, 0, 1,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM objs),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return a list containing @var{objs}, the arguments to\n"
|
|
|
|
|
|
"@code{list}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_list
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
return objs;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-06-19 10:04:31 +00:00
|
|
|
|
#if (SCM_DEBUG_DEPRECATED == 0)
|
|
|
|
|
|
|
|
|
|
|
|
SCM_REGISTER_PROC (s_list_star, "list*", 1, 0, 1, scm_cons_star);
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SCM_DEBUG_DEPRECATED == 0 */
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_cons_star, "cons*", 1, 0, 1,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM arg, SCM rest),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Like @code{list}, but the last arg provides the tail of the\n"
|
|
|
|
|
|
"constructed list, returning @code{(cons @var{arg1} (cons\n"
|
2001-03-23 16:14:47 +00:00
|
|
|
|
"@var{arg2} (cons @dots{} @var{argn})))}. Requires at least one\n"
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"argument. If given one argument, that argument is returned as\n"
|
|
|
|
|
|
"result. This function is called @code{list*} in some other\n"
|
|
|
|
|
|
"Schemes and in Common LISP.")
|
2000-06-19 10:04:31 +00:00
|
|
|
|
#define FUNC_NAME s_scm_cons_star
|
1999-03-11 11:46:16 +00:00
|
|
|
|
{
|
2000-05-18 08:47:52 +00:00
|
|
|
|
SCM_VALIDATE_REST_ARGUMENT (rest);
|
|
|
|
|
|
if (!SCM_NULLP (rest))
|
1999-03-11 11:46:16 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM prev = arg = scm_cons (arg, rest);
|
2000-01-06 18:00:33 +00:00
|
|
|
|
while (SCM_NNULLP (SCM_CDR (rest)))
|
1999-03-11 11:46:16 +00:00
|
|
|
|
{
|
|
|
|
|
|
prev = rest;
|
|
|
|
|
|
rest = SCM_CDR (rest);
|
|
|
|
|
|
}
|
|
|
|
|
|
SCM_SETCDR (prev, SCM_CAR (rest));
|
|
|
|
|
|
}
|
|
|
|
|
|
return arg;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1999-03-11 11:46:16 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* general questions about lists --- null?, list?, length, etc. */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_null_p, "null?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is the empty list, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_null_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-01-20 20:59:33 +00:00
|
|
|
|
return SCM_BOOL (SCM_NULLP (x));
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-20 20:59:33 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_list_p, "list?", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return @code{#t} iff @var{x} is a proper list, else @code{#f}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_list_p
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-01-20 20:59:33 +00:00
|
|
|
|
return SCM_BOOL (scm_ilength (x) >= 0);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* Return the length of SX, or -1 if it's not a proper list.
|
1996-11-10 03:11:46 +00:00
|
|
|
|
This uses the "tortoise and hare" algorithm to detect "infinitely
|
1996-10-03 05:17:17 +00:00
|
|
|
|
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
|
1999-12-12 02:36:16 +00:00
|
|
|
|
scm_ilength(SCM sx)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-01-06 18:00:33 +00:00
|
|
|
|
long i = 0;
|
|
|
|
|
|
SCM tortoise = sx;
|
|
|
|
|
|
SCM hare = sx;
|
1996-10-03 05:17:17 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
do {
|
2000-01-06 18:00:33 +00:00
|
|
|
|
if (SCM_NULLP(hare)) return i;
|
1999-06-19 20:21:07 +00:00
|
|
|
|
if (SCM_NCONSP(hare)) return -1;
|
1996-10-03 05:17:17 +00:00
|
|
|
|
hare = SCM_CDR(hare);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
i++;
|
2000-01-06 18:00:33 +00:00
|
|
|
|
if (SCM_NULLP(hare)) return i;
|
1999-06-19 20:21:07 +00:00
|
|
|
|
if (SCM_NCONSP(hare)) return -1;
|
1996-10-03 05:17:17 +00:00
|
|
|
|
hare = SCM_CDR(hare);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
i++;
|
1996-11-10 03:11:46 +00:00
|
|
|
|
/* For every two steps the hare takes, the tortoise takes one. */
|
|
|
|
|
|
tortoise = SCM_CDR(tortoise);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2000-03-29 16:22:57 +00:00
|
|
|
|
while (! SCM_EQ_P (hare, tortoise));
|
1996-10-03 05:17:17 +00:00
|
|
|
|
|
1996-11-10 03:11:46 +00:00
|
|
|
|
/* If the tortoise ever catches the hare, then the list must contain
|
1996-10-03 05:17:17 +00:00
|
|
|
|
a cycle. */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2000-01-20 20:59:33 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_length, "length", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return the number of elements in list @var{lst}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_length
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
int i;
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_VALIDATE_LIST_COPYLEN (1,lst,i);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return SCM_MAKINUM (i);
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* appending lists */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_append, "append", 0, 0, 1,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM args),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return a list consisting of the elements the lists passed as\n"
|
|
|
|
|
|
"arguments.\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"@lisp\n"
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"(append '(x) '(y)) @result{} (x y)\n"
|
|
|
|
|
|
"(append '(a) '(b c d)) @result{} (a b c d)\n"
|
|
|
|
|
|
"(append '(a (b)) '((c))) @result{} (a (b) (c))\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"@end lisp\n"
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"The resulting list is always newly allocated, except that it\n"
|
|
|
|
|
|
"shares structure with the last list argument. The last\n"
|
|
|
|
|
|
"argument may actually be any object; an improper list results\n"
|
|
|
|
|
|
"if the last argument is not a proper list.\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"@lisp\n"
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"(append '(a b) '(c . d)) @result{} (a b c . d)\n"
|
|
|
|
|
|
"(append '() 'a) @result{} a\n"
|
2001-04-03 13:19:05 +00:00
|
|
|
|
"@end lisp")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_append
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-05-18 08:47:52 +00:00
|
|
|
|
SCM_VALIDATE_REST_ARGUMENT (args);
|
|
|
|
|
|
if (SCM_NULLP (args)) {
|
|
|
|
|
|
return SCM_EOL;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
SCM res = SCM_EOL;
|
|
|
|
|
|
SCM *lloc = &res;
|
|
|
|
|
|
SCM arg = SCM_CAR (args);
|
|
|
|
|
|
args = SCM_CDR (args);
|
|
|
|
|
|
while (!SCM_NULLP (args)) {
|
|
|
|
|
|
while (SCM_CONSP (arg)) {
|
|
|
|
|
|
*lloc = scm_cons (SCM_CAR (arg), SCM_EOL);
|
|
|
|
|
|
lloc = SCM_CDRLOC (*lloc);
|
|
|
|
|
|
arg = SCM_CDR (arg);
|
|
|
|
|
|
}
|
|
|
|
|
|
SCM_VALIDATE_NULL (SCM_ARGn, arg);
|
|
|
|
|
|
arg = SCM_CAR (args);
|
|
|
|
|
|
args = SCM_CDR (args);
|
|
|
|
|
|
};
|
|
|
|
|
|
*lloc = arg;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_append_x, "append!", 0, 0, 1,
|
2001-04-03 13:19:05 +00:00
|
|
|
|
(SCM lists),
|
|
|
|
|
|
"A destructive version of @code{append} (@pxref{Pairs and\n"
|
|
|
|
|
|
"Lists,,,r4rs, The Revised^4 Report on Scheme}). The cdr field\n"
|
|
|
|
|
|
"of each list's final pair is changed to point to the head of\n"
|
|
|
|
|
|
"the next list, so no consing is performed. Return a pointer to\n"
|
|
|
|
|
|
"the mutated list.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_append_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-04-03 13:19:05 +00:00
|
|
|
|
SCM_VALIDATE_REST_ARGUMENT (lists);
|
2000-05-18 08:47:52 +00:00
|
|
|
|
while (1) {
|
2001-04-03 13:19:05 +00:00
|
|
|
|
if (SCM_NULLP (lists)) {
|
2000-05-18 08:47:52 +00:00
|
|
|
|
return SCM_EOL;
|
|
|
|
|
|
} else {
|
2001-04-03 13:19:05 +00:00
|
|
|
|
SCM arg = SCM_CAR (lists);
|
|
|
|
|
|
lists = SCM_CDR (lists);
|
|
|
|
|
|
if (SCM_NULLP (lists)) {
|
2000-05-18 08:47:52 +00:00
|
|
|
|
return arg;
|
|
|
|
|
|
} else if (!SCM_NULLP (arg)) {
|
|
|
|
|
|
SCM_VALIDATE_CONS (SCM_ARG1, arg);
|
2001-04-03 13:19:05 +00:00
|
|
|
|
SCM_SETCDR (scm_last_pair (arg), scm_append_x (lists));
|
2000-05-18 08:47:52 +00:00
|
|
|
|
return arg;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_last_pair, "last-pair", 1, 0, 0,
|
2000-01-06 18:00:33 +00:00
|
|
|
|
(SCM lst),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Return a pointer to the last pair in @var{lst}, signalling an error if\n"
|
|
|
|
|
|
"@var{lst} is circular.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_last_pair
|
1996-10-03 05:17:17 +00:00
|
|
|
|
{
|
2000-01-06 18:00:33 +00:00
|
|
|
|
SCM tortoise = lst;
|
|
|
|
|
|
SCM hare = lst;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 18:00:33 +00:00
|
|
|
|
if (SCM_NULLP (lst))
|
1996-10-03 05:17:17 +00:00
|
|
|
|
return SCM_EOL;
|
|
|
|
|
|
|
2000-01-06 18:00:33 +00:00
|
|
|
|
SCM_VALIDATE_CONS (SCM_ARG1, lst);
|
|
|
|
|
|
do {
|
|
|
|
|
|
SCM ahead = SCM_CDR(hare);
|
|
|
|
|
|
if (SCM_NCONSP(ahead)) return hare;
|
|
|
|
|
|
hare = ahead;
|
|
|
|
|
|
ahead = SCM_CDR(hare);
|
|
|
|
|
|
if (SCM_NCONSP(ahead)) return hare;
|
|
|
|
|
|
hare = ahead;
|
|
|
|
|
|
tortoise = SCM_CDR(tortoise);
|
1996-10-03 05:17:17 +00:00
|
|
|
|
}
|
2000-03-29 16:22:57 +00:00
|
|
|
|
while (! SCM_EQ_P (hare, tortoise));
|
* dynl.c, feature.c, filesys.c, fports.c, list.c, load.c,
net_db.c, sort.c, stacks.c, unif.c: Use SCM_WTA, SCM_MISC_ERROR
where possible.
* symbols.c (scm_sysintern0): Fixed the function name in a
scm_misc_error invocation.
* print.c (scm_simple_format): Do not need SCM_COERCE_SUBSTR, and
use scm_return_first to ward off latent GC bug that Mikael caught.
* async.c: Use SCM_VALIDATE_ASYNC_COPY one place where it wasn't
used before but should've been.
2000-01-11 23:56:47 +00:00
|
|
|
|
SCM_MISC_ERROR ("Circular structure in position 1: ~S", SCM_LIST1 (lst));
|
1996-10-03 05:17:17 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-03 05:17:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* reversing lists */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_reverse, "reverse", 1, 0, 0,
|
2000-01-06 18:00:33 +00:00
|
|
|
|
(SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return a new list that contains the elements of @var{lst} but\n"
|
|
|
|
|
|
"in reverse order.")
|
2000-01-06 18:00:33 +00:00
|
|
|
|
#define FUNC_NAME s_scm_reverse
|
|
|
|
|
|
{
|
|
|
|
|
|
SCM result = SCM_EOL;
|
|
|
|
|
|
SCM tortoise = lst;
|
|
|
|
|
|
SCM hare = lst;
|
|
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
if (SCM_NULLP(hare)) return result;
|
|
|
|
|
|
SCM_ASSERT(SCM_CONSP(hare), lst, 1, FUNC_NAME);
|
|
|
|
|
|
result = scm_cons (SCM_CAR (hare), result);
|
|
|
|
|
|
hare = SCM_CDR (hare);
|
|
|
|
|
|
if (SCM_NULLP(hare)) return result;
|
|
|
|
|
|
SCM_ASSERT(SCM_CONSP(hare), lst, 1, FUNC_NAME);
|
|
|
|
|
|
result = scm_cons (SCM_CAR (hare), result);
|
|
|
|
|
|
hare = SCM_CDR (hare);
|
|
|
|
|
|
tortoise = SCM_CDR (tortoise);
|
|
|
|
|
|
}
|
2000-03-29 16:22:57 +00:00
|
|
|
|
while (! SCM_EQ_P (hare, tortoise));
|
* dynl.c, feature.c, filesys.c, fports.c, list.c, load.c,
net_db.c, sort.c, stacks.c, unif.c: Use SCM_WTA, SCM_MISC_ERROR
where possible.
* symbols.c (scm_sysintern0): Fixed the function name in a
scm_misc_error invocation.
* print.c (scm_simple_format): Do not need SCM_COERCE_SUBSTR, and
use scm_return_first to ward off latent GC bug that Mikael caught.
* async.c: Use SCM_VALIDATE_ASYNC_COPY one place where it wasn't
used before but should've been.
2000-01-11 23:56:47 +00:00
|
|
|
|
SCM_MISC_ERROR ("Circular structure in position 1: ~S", SCM_LIST1 (lst));
|
2000-01-06 18:00:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
#undef FUNC_NAME
|
|
|
|
|
|
|
|
|
|
|
|
SCM_DEFINE (scm_reverse_x, "reverse!", 1, 1, 0,
|
|
|
|
|
|
(SCM lst, SCM new_tail),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"A destructive version of @code{reverse} (@pxref{Pairs and Lists,,,r4rs,\n"
|
|
|
|
|
|
"The Revised^4 Report on Scheme}). The cdr of each cell in @var{lst} is\n"
|
|
|
|
|
|
"modified to point to the previous list element. Return a pointer to the\n"
|
|
|
|
|
|
"head of the reversed list.\n\n"
|
|
|
|
|
|
"Caveat: because the list is modified in place, the tail of the original\n"
|
|
|
|
|
|
"list now becomes its head, and the head of the original list now becomes\n"
|
|
|
|
|
|
"the tail. Therefore, the @var{lst} symbol to which the head of the\n"
|
|
|
|
|
|
"original list was bound now points to the tail. To ensure that the head\n"
|
|
|
|
|
|
"of the modified list is not lost, it is wise to save the return value of\n"
|
|
|
|
|
|
"@code{reverse!}")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_reverse_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2001-03-11 23:47:16 +00:00
|
|
|
|
SCM_VALIDATE_LIST (1, lst);
|
1999-03-16 16:37:51 +00:00
|
|
|
|
if (SCM_UNBNDP (new_tail))
|
|
|
|
|
|
new_tail = SCM_EOL;
|
|
|
|
|
|
else
|
2001-03-11 23:47:16 +00:00
|
|
|
|
SCM_VALIDATE_LIST (2, new_tail);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-06 18:00:33 +00:00
|
|
|
|
while (SCM_NNULLP (lst))
|
1999-03-16 16:37:51 +00:00
|
|
|
|
{
|
2000-01-06 18:00:33 +00:00
|
|
|
|
SCM old_tail = SCM_CDR (lst);
|
|
|
|
|
|
SCM_SETCDR (lst, new_tail);
|
|
|
|
|
|
new_tail = lst;
|
|
|
|
|
|
lst = old_tail;
|
1999-03-16 16:37:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
return new_tail;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-06-30 10:46:35 +00:00
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* indexing lists by element number */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_list_ref, "list-ref", 2, 0, 0,
|
2000-06-30 10:46:35 +00:00
|
|
|
|
(SCM list, SCM k),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return the @var{k}th element from @var{list}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_list_ref
|
|
|
|
|
|
{
|
2000-06-30 10:46:35 +00:00
|
|
|
|
SCM lst = list;
|
|
|
|
|
|
unsigned long int i;
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_VALIDATE_INUM_MIN_COPY (2,k,0,i);
|
2000-06-30 10:46:35 +00:00
|
|
|
|
while (SCM_CONSP (lst)) {
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
|
return SCM_CAR (lst);
|
|
|
|
|
|
else {
|
|
|
|
|
|
--i;
|
|
|
|
|
|
lst = SCM_CDR (lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
if (SCM_NULLP (lst))
|
|
|
|
|
|
SCM_OUT_OF_RANGE (2, k);
|
|
|
|
|
|
else
|
|
|
|
|
|
SCM_WRONG_TYPE_ARG (1, list);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-06-30 10:46:35 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_list_set_x, "list-set!", 3, 0, 0,
|
2000-06-30 10:46:35 +00:00
|
|
|
|
(SCM list, SCM k, SCM val),
|
|
|
|
|
|
"Set the @var{k}th element of @var{list} to @var{val}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_list_set_x
|
|
|
|
|
|
{
|
2000-06-30 10:46:35 +00:00
|
|
|
|
SCM lst = list;
|
|
|
|
|
|
unsigned long int i;
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_VALIDATE_INUM_MIN_COPY (2,k,0,i);
|
2000-06-30 10:46:35 +00:00
|
|
|
|
while (SCM_CONSP (lst)) {
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
|
SCM_SETCAR (lst, val);
|
|
|
|
|
|
return val;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
--i;
|
|
|
|
|
|
lst = SCM_CDR (lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
if (SCM_NULLP (lst))
|
|
|
|
|
|
SCM_OUT_OF_RANGE (2, k);
|
|
|
|
|
|
else
|
|
|
|
|
|
SCM_WRONG_TYPE_ARG (1, list);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM_REGISTER_PROC(s_list_cdr_ref, "list-cdr-ref", 2, 0, 0, scm_list_tail);
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_list_tail, "list-tail", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM lst, SCM k),
|
2000-08-11 15:12:37 +00:00
|
|
|
|
"@deffnx primitive list-cdr-ref lst k\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Return the \"tail\" of @var{lst} beginning with its @var{k}th element.\n"
|
|
|
|
|
|
"The first element of the list is considered to be element 0.\n\n"
|
2000-08-11 15:12:37 +00:00
|
|
|
|
"@code{list-tail} and @code{list-cdr-ref} are identical. It may help to\n"
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"think of @code{list-cdr-ref} as accessing the @var{k}th cdr of the list,\n"
|
|
|
|
|
|
"or returning the results of cdring @var{k} times down @var{lst}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_list_tail
|
1996-10-03 05:17:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
register long i;
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_VALIDATE_INUM_MIN_COPY (2,k,0,i);
|
1996-10-03 05:17:17 +00:00
|
|
|
|
while (i-- > 0) {
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_VALIDATE_CONS (1,lst);
|
1996-10-03 05:17:17 +00:00
|
|
|
|
lst = SCM_CDR(lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-03 05:17:17 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_list_cdr_set_x, "list-cdr-set!", 3, 0, 0,
|
2000-06-30 10:46:35 +00:00
|
|
|
|
(SCM list, SCM k, SCM val),
|
|
|
|
|
|
"Set the @var{k}th cdr of @var{list} to @var{val}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_list_cdr_set_x
|
|
|
|
|
|
{
|
2000-06-30 10:46:35 +00:00
|
|
|
|
SCM lst = list;
|
|
|
|
|
|
unsigned long int i;
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_VALIDATE_INUM_MIN_COPY (2,k,0,i);
|
2000-06-30 10:46:35 +00:00
|
|
|
|
while (SCM_CONSP (lst)) {
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
|
SCM_SETCDR (lst, val);
|
|
|
|
|
|
return val;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
--i;
|
|
|
|
|
|
lst = SCM_CDR (lst);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
if (SCM_NULLP (lst))
|
|
|
|
|
|
SCM_OUT_OF_RANGE (2, k);
|
|
|
|
|
|
else
|
|
|
|
|
|
SCM_WRONG_TYPE_ARG (1, list);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* copying lists, perhaps partially */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_list_head, "list-head", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM lst, SCM k),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Copy the first @var{k} elements from @var{lst} into a new list, and\n"
|
|
|
|
|
|
"return it.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_list_head
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM answer;
|
|
|
|
|
|
SCM * pos;
|
|
|
|
|
|
register long i;
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_VALIDATE_INUM_MIN_COPY (2,k,0,i);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
answer = SCM_EOL;
|
|
|
|
|
|
pos = &answer;
|
|
|
|
|
|
while (i-- > 0)
|
|
|
|
|
|
{
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_VALIDATE_CONS (1,lst);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*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;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_list_copy, "list-copy", 1, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM lst),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"Return a (newly-created) copy of @var{lst}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_list_copy
|
1996-10-03 05:17:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM newlst;
|
|
|
|
|
|
SCM * fill_here;
|
|
|
|
|
|
SCM from_here;
|
|
|
|
|
|
|
2001-02-12 21:45:22 +00:00
|
|
|
|
SCM_VALIDATE_LIST (1, lst);
|
|
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
newlst = SCM_EOL;
|
|
|
|
|
|
fill_here = &newlst;
|
|
|
|
|
|
from_here = lst;
|
|
|
|
|
|
|
1999-12-16 20:48:05 +00:00
|
|
|
|
while (SCM_CONSP (from_here))
|
1996-10-03 05:17:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-10-03 05:17:17 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1996-10-03 05:17:17 +00:00
|
|
|
|
/* membership tests (memq, memv, etc.) */
|
|
|
|
|
|
|
2000-10-13 07:55:25 +00:00
|
|
|
|
#if SCM_DEBUG_DEPRECATED == 0
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_sloppy_memq, "sloppy-memq", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM lst),
|
* arbiters.c, eq.c, gc.c, guardians.c, list.c, ports.c, print.c,
regex-posix.c, scmsigs.c, stime.c, strings.c, variable.c, stime.c,
strings.c, variable.c: Added lots of documentation, cleaned up
some existing documentation. Occasionally changed formal params
to match docs. Also folded an #ifdef into the inners of a
primitive instead of having two copies of the primitive
(`get-internal-real-time', from stime.c)
2000-02-14 03:13:19 +00:00
|
|
|
|
"This procedure behaves like @code{memq}, but does no type or error checking.\n"
|
|
|
|
|
|
"Its use is recommended only in writing Guile internals,\n"
|
|
|
|
|
|
"not for high-level Scheme programs.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_sloppy_memq
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1999-12-16 20:48:05 +00:00
|
|
|
|
for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-03-29 16:22:57 +00:00
|
|
|
|
if (SCM_EQ_P (SCM_CAR (lst), x))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_sloppy_memv, "sloppy-memv", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM lst),
|
* arbiters.c, eq.c, gc.c, guardians.c, list.c, ports.c, print.c,
regex-posix.c, scmsigs.c, stime.c, strings.c, variable.c, stime.c,
strings.c, variable.c: Added lots of documentation, cleaned up
some existing documentation. Occasionally changed formal params
to match docs. Also folded an #ifdef into the inners of a
primitive instead of having two copies of the primitive
(`get-internal-real-time', from stime.c)
2000-02-14 03:13:19 +00:00
|
|
|
|
"This procedure behaves like @code{memv}, but does no type or error checking.\n"
|
|
|
|
|
|
"Its use is recommended only in writing Guile internals,\n"
|
|
|
|
|
|
"not for high-level Scheme programs.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_sloppy_memv
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1999-12-16 20:48:05 +00:00
|
|
|
|
for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-03-29 16:22:57 +00:00
|
|
|
|
if (! SCM_FALSEP (scm_eqv_p (SCM_CAR (lst), x)))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_sloppy_member, "sloppy-member", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM lst),
|
* arbiters.c, eq.c, gc.c, guardians.c, list.c, ports.c, print.c,
regex-posix.c, scmsigs.c, stime.c, strings.c, variable.c, stime.c,
strings.c, variable.c: Added lots of documentation, cleaned up
some existing documentation. Occasionally changed formal params
to match docs. Also folded an #ifdef into the inners of a
primitive instead of having two copies of the primitive
(`get-internal-real-time', from stime.c)
2000-02-14 03:13:19 +00:00
|
|
|
|
"This procedure behaves like @code{member}, but does no type or error checking.\n"
|
|
|
|
|
|
"Its use is recommended only in writing Guile internals,\n"
|
|
|
|
|
|
"not for high-level Scheme programs.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_sloppy_member
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1999-12-16 20:48:05 +00:00
|
|
|
|
for(; SCM_CONSP (lst); lst = SCM_CDR(lst))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-03-29 16:22:57 +00:00
|
|
|
|
if (! SCM_FALSEP (scm_equal_p (SCM_CAR (lst), x)))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-10-13 07:55:25 +00:00
|
|
|
|
#endif /* DEPRECATED */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-12-01 17:57:42 +00:00
|
|
|
|
/* The function scm_c_memq returns the first sublist of list whose car is
|
|
|
|
|
|
* 'eq?' obj, where the sublists of list are the non-empty lists returned by
|
|
|
|
|
|
* (list-tail list k) for k less than the length of list. If obj does not
|
2001-04-03 13:19:05 +00:00
|
|
|
|
* occur in list, then #f (not the empty list) is returned.
|
2000-12-01 17:57:42 +00:00
|
|
|
|
* List must be a proper list, otherwise scm_c_memq may crash or loop
|
|
|
|
|
|
* endlessly.
|
|
|
|
|
|
*/
|
|
|
|
|
|
SCM
|
|
|
|
|
|
scm_c_memq (SCM obj, SCM list)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (; !SCM_NULLP (list); list = SCM_CDR (list))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SCM_EQ_P (SCM_CAR (list), obj))
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
return SCM_BOOL_F;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_memq, "memq", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return the first sublist of @var{lst} whose car is @code{eq?}\n"
|
|
|
|
|
|
"to @var{x} where the sublists of @var{lst} are the non-empty\n"
|
|
|
|
|
|
"lists returned by @code{(list-tail @var{lst} @var{k})} for\n"
|
|
|
|
|
|
"@var{k} less than the length of @var{lst}. If @var{x} does not\n"
|
|
|
|
|
|
"occur in @var{lst}, then @code{#f} (not the empty list) is\n"
|
|
|
|
|
|
"returned.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_memq
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-10-13 07:55:25 +00:00
|
|
|
|
SCM_VALIDATE_LIST (2, lst);
|
2000-12-01 17:57:42 +00:00
|
|
|
|
return scm_c_memq (x, lst);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_memv, "memv", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return the first sublist of @var{lst} whose car is @code{eqv?}\n"
|
|
|
|
|
|
"to @var{x} where the sublists of @var{lst} are the non-empty\n"
|
|
|
|
|
|
"lists returned by @code{(list-tail @var{lst} @var{k})} for\n"
|
|
|
|
|
|
"@var{k} less than the length of @var{lst}. If @var{x} does not\n"
|
|
|
|
|
|
"occur in @var{lst}, then @code{#f} (not the empty list) is\n"
|
|
|
|
|
|
"returned.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_memv
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-10-13 07:55:25 +00:00
|
|
|
|
SCM_VALIDATE_LIST (2, lst);
|
|
|
|
|
|
for (; !SCM_NULLP (lst); lst = SCM_CDR (lst))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (! SCM_FALSEP (scm_eqv_p (SCM_CAR (lst), x)))
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
return SCM_BOOL_F;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_member, "member", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM x, SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return the first sublist of @var{lst} whose car is\n"
|
|
|
|
|
|
"@code{equal?} to @var{x} where the sublists of @var{lst} are\n"
|
|
|
|
|
|
"the non-empty lists returned by @code{(list-tail @var{lst}\n"
|
|
|
|
|
|
"@var{k})} for @var{k} less than the length of @var{lst}. If\n"
|
|
|
|
|
|
"@var{x} does not occur in @var{lst}, then @code{#f} (not the\n"
|
|
|
|
|
|
"empty list) is returned.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_member
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-10-13 07:55:25 +00:00
|
|
|
|
SCM_VALIDATE_LIST (2, lst);
|
|
|
|
|
|
for (; !SCM_NULLP (lst); lst = SCM_CDR (lst))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (! SCM_FALSEP (scm_equal_p (SCM_CAR (lst), x)))
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
|
|
|
|
|
return SCM_BOOL_F;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
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
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_delq_x, "delq!", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM item, SCM lst),
|
* alist.c, chars.c, debug.c, dynl.c, dynwind.c, error.c, eval.c,
evalext.c, filesys.c, gc.c, hash.c, hashtab.c, ioext.c,
keywords.c, list.c, load.c, macros.c, net_db.c, numbers.c,
objprop.c, ports.c, posix.c, print.c, procprop.c, procs.c,
ramap.c, regex-posix.c, root.c, scmsigs.c, simpos.c, socket.c,
stacks.c, stime.c, strings.c, strop.c, strports.c, struct.c,
symbols.c, throw.c, unif.c, vectors.c, version.c, vports.c,
weaks.c: Converted docstrings to ANSI C format.
2000-01-18 11:24:03 +00:00
|
|
|
|
"@deffnx primitive delv! item lst\n"
|
|
|
|
|
|
"@deffnx primitive delete! item lst\n"
|
|
|
|
|
|
"These procedures are destructive versions of @code{delq}, @code{delv}\n"
|
|
|
|
|
|
"and @code{delete}: they modify the pointers in the existing @var{lst}\n"
|
|
|
|
|
|
"rather than creating a new list. Caveat evaluator: Like other\n"
|
|
|
|
|
|
"destructive list functions, these functions cannot modify the binding of\n"
|
|
|
|
|
|
"@var{lst}, and so cannot be used to delete the first element of\n"
|
|
|
|
|
|
"@var{lst} destructively.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_delq_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1996-12-23 04:37:17 +00:00
|
|
|
|
SCM walk;
|
|
|
|
|
|
SCM *prev;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1996-12-23 04:37:17 +00:00
|
|
|
|
for (prev = &lst, walk = lst;
|
1999-12-16 20:48:05 +00:00
|
|
|
|
SCM_CONSP (walk);
|
1996-12-23 04:37:17 +00:00
|
|
|
|
walk = SCM_CDR (walk))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-03-29 16:22:57 +00:00
|
|
|
|
if (SCM_EQ_P (SCM_CAR (walk), item))
|
1996-12-23 04:37:17 +00:00
|
|
|
|
*prev = SCM_CDR (walk);
|
|
|
|
|
|
else
|
|
|
|
|
|
prev = SCM_CDRLOC (walk);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1996-12-23 04:37:17 +00:00
|
|
|
|
|
|
|
|
|
|
return lst;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_delv_x, "delv!", 2, 0, 0,
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
(SCM item, SCM lst),
|
|
|
|
|
|
"Destructively remove all elements from @var{lst} that are\n"
|
|
|
|
|
|
"@code{eqv?} to @var{item}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_delv_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1996-12-23 04:37:17 +00:00
|
|
|
|
SCM walk;
|
|
|
|
|
|
SCM *prev;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1996-12-23 04:37:17 +00:00
|
|
|
|
for (prev = &lst, walk = lst;
|
1999-12-16 20:48:05 +00:00
|
|
|
|
SCM_CONSP (walk);
|
1996-12-23 04:37:17 +00:00
|
|
|
|
walk = SCM_CDR (walk))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-03-29 16:22:57 +00:00
|
|
|
|
if (! SCM_FALSEP (scm_eqv_p (SCM_CAR (walk), item)))
|
1996-12-23 04:37:17 +00:00
|
|
|
|
*prev = SCM_CDR (walk);
|
|
|
|
|
|
else
|
|
|
|
|
|
prev = SCM_CDRLOC (walk);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1996-12-23 04:37:17 +00:00
|
|
|
|
|
|
|
|
|
|
return lst;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_delete_x, "delete!", 2, 0, 0,
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
(SCM item, SCM lst),
|
|
|
|
|
|
"Destructively remove all elements from @var{lst} that are\n"
|
|
|
|
|
|
"@code{equal?} to @var{item}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_delete_x
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1996-12-23 04:37:17 +00:00
|
|
|
|
SCM walk;
|
|
|
|
|
|
SCM *prev;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
1996-12-23 04:37:17 +00:00
|
|
|
|
for (prev = &lst, walk = lst;
|
1999-12-16 20:48:05 +00:00
|
|
|
|
SCM_CONSP (walk);
|
1996-12-23 04:37:17 +00:00
|
|
|
|
walk = SCM_CDR (walk))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
2000-03-29 16:22:57 +00:00
|
|
|
|
if (! SCM_FALSEP (scm_equal_p (SCM_CAR (walk), item)))
|
1996-12-23 04:37:17 +00:00
|
|
|
|
*prev = SCM_CDR (walk);
|
|
|
|
|
|
else
|
|
|
|
|
|
prev = SCM_CDRLOC (walk);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1996-12-23 04:37:17 +00:00
|
|
|
|
|
|
|
|
|
|
return lst;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_delq, "delq", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM item, SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return a newly-created copy of @var{lst} with elements\n"
|
|
|
|
|
|
"@code{eq?} to @var{item} removed. This procedure mirrors\n"
|
|
|
|
|
|
"@code{memq}: @code{delq} compares elements of @var{lst} against\n"
|
|
|
|
|
|
"@var{item} with @code{eq?}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_delq
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM copy = scm_list_copy (lst);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return scm_delq_x (item, copy);
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_delv, "delv", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM item, SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return a newly-created copy of @var{lst} with elements\n"
|
|
|
|
|
|
"@code{eqv?} to @var{item} removed. This procedure mirrors\n"
|
|
|
|
|
|
"@code{memv}: @code{delv} compares elements of @var{lst} against\n"
|
|
|
|
|
|
"@var{item} with @code{eqv?}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_delv
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM copy = scm_list_copy (lst);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return scm_delv_x (item, copy);
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-01-05 19:05:23 +00:00
|
|
|
|
SCM_DEFINE (scm_delete, "delete", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM item, SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Return a newly-created copy of @var{lst} with elements\n"
|
|
|
|
|
|
"@code{equal?} to @var{item} removed. This procedure mirrors\n"
|
|
|
|
|
|
"@code{member}: @code{delete} compares elements of @var{lst}\n"
|
|
|
|
|
|
"against @var{item} with @code{equal?}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_delete
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
1999-12-12 02:36:16 +00:00
|
|
|
|
SCM copy = scm_list_copy (lst);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
return scm_delete_x (item, copy);
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_delq1_x, "delq1!", 2, 0, 0,
|
1999-12-12 02:36:16 +00:00
|
|
|
|
(SCM item, SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Like @code{delq!}, but only deletes the first occurrence of\n"
|
|
|
|
|
|
"@var{item} from @var{lst}. Tests for equality using\n"
|
|
|
|
|
|
"@code{eq?}. See also @code{delv1!} and @code{delete1!}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_delq1_x
|
1998-11-03 16:08:28 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM walk;
|
|
|
|
|
|
SCM *prev;
|
|
|
|
|
|
|
|
|
|
|
|
for (prev = &lst, walk = lst;
|
1999-12-16 20:48:05 +00:00
|
|
|
|
SCM_CONSP (walk);
|
1998-11-03 16:08:28 +00:00
|
|
|
|
walk = SCM_CDR (walk))
|
|
|
|
|
|
{
|
2000-03-29 16:22:57 +00:00
|
|
|
|
if (SCM_EQ_P (SCM_CAR (walk), item))
|
1998-11-03 16:08:28 +00:00
|
|
|
|
{
|
|
|
|
|
|
*prev = SCM_CDR (walk);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
prev = SCM_CDRLOC (walk);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1998-11-03 16:08:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_delv1_x, "delv1!", 2, 0, 0,
|
2000-03-02 23:14:28 +00:00
|
|
|
|
(SCM item, SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Like @code{delv!}, but only deletes the first occurrence of\n"
|
|
|
|
|
|
"@var{item} from @var{lst}. Tests for equality using\n"
|
|
|
|
|
|
"@code{eqv?}. See also @code{delq1!} and @code{delete1!}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_delv1_x
|
1998-11-03 16:08:28 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM walk;
|
|
|
|
|
|
SCM *prev;
|
|
|
|
|
|
|
|
|
|
|
|
for (prev = &lst, walk = lst;
|
1999-12-16 20:48:05 +00:00
|
|
|
|
SCM_CONSP (walk);
|
1998-11-03 16:08:28 +00:00
|
|
|
|
walk = SCM_CDR (walk))
|
|
|
|
|
|
{
|
2000-03-29 16:22:57 +00:00
|
|
|
|
if (! SCM_FALSEP (scm_eqv_p (SCM_CAR (walk), item)))
|
1998-11-03 16:08:28 +00:00
|
|
|
|
{
|
|
|
|
|
|
*prev = SCM_CDR (walk);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
prev = SCM_CDRLOC (walk);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1998-11-03 16:08:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-01-05 19:25:37 +00:00
|
|
|
|
SCM_DEFINE (scm_delete1_x, "delete1!", 2, 0, 0,
|
2000-03-02 23:14:28 +00:00
|
|
|
|
(SCM item, SCM lst),
|
* list.c (scm_list, scm_cons_star, scm_null_p, scm_list_p),
(scm_length, scm_append, scm_reverse, scm_list_ref),
(scm_memq, scm_memv, scm_member, scm_delv_x, scm_delete_x),
(scm_delq, scm_delv, scm_delete, scm_delq1_x, scm_delv1_x),
(scm_delete1_x), gc.c (scm_map_free_list),
(scm_free_list_length), hash.c (scm_hashq, scm_hashv),
(scm_hash), hashtab.c (scm_hashq_ref, scm_hashq_set_x),
(scm_hashq_remove_x, scm_hashv_ref, scm_hashv_set_x),
(scm_hashv_remove_x, scm_hash_ref, scm_hash_set_x),
(scm_hash_remove_x), ports.c (scm_pt_size, scm_pt_member), print.c
(scm_current_pstate), scmsigs.c (scm_usleep), goops.c
(scm_get_keyword, scm_sys_compute_slots): Added texinfo markup.
* weaks.c (scm_weak_vector_p, scm_weak_key_hash_table_p),
(scm_weak_value_hash_table_p, scm_doubly_weak_hash_table_p),
rdelim.c (scm_read_delimited_x), strop.c (scm_string_index),
symbols.c (scm_symbol_interned_p), numbers.c
(scm_string_to_number), ports.c (scm_port_p): Corrected texinfo
markup.
2001-03-16 10:00:17 +00:00
|
|
|
|
"Like @code{delete!}, but only deletes the first occurrence of\n"
|
|
|
|
|
|
"@var{item} from @var{lst}. Tests for equality using\n"
|
|
|
|
|
|
"@code{equal?}. See also @code{delq1!} and @code{delv1!}.")
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#define FUNC_NAME s_scm_delete1_x
|
1998-11-03 16:08:28 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM walk;
|
|
|
|
|
|
SCM *prev;
|
|
|
|
|
|
|
|
|
|
|
|
for (prev = &lst, walk = lst;
|
1999-12-16 20:48:05 +00:00
|
|
|
|
SCM_CONSP (walk);
|
1998-11-03 16:08:28 +00:00
|
|
|
|
walk = SCM_CDR (walk))
|
|
|
|
|
|
{
|
2000-03-29 16:22:57 +00:00
|
|
|
|
if (! SCM_FALSEP (scm_equal_p (SCM_CAR (walk), item)))
|
1998-11-03 16:08:28 +00:00
|
|
|
|
{
|
|
|
|
|
|
*prev = SCM_CDR (walk);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
prev = SCM_CDRLOC (walk);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return lst;
|
|
|
|
|
|
}
|
1999-12-12 02:36:16 +00:00
|
|
|
|
#undef FUNC_NAME
|
1998-11-03 16:08:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
scm_init_list ()
|
|
|
|
|
|
{
|
* alist.c, arbiters.c, async.c, backtrace.c, boolean.c, chars.c,
continuations.c, debug-malloc.c, debug.c, dynl.c, dynwind.c,
environments.c, eq.c, error.c, eval.c, evalext.c, feature.c,
filesys.c, fluids.c, fports.c, gc.c, goops.c, guardians.c, hash.c,
hashtab.c, hooks.c, ioext.c, iselect.c, keywords.c, lang.c,
list.c, load.c, macros.c, modules.c, net_db.c, numbers.c,
objects.c, objprop.c, options.c, pairs.c, ports.c, posix.c,
print.c, procprop.c, procs.c, properties.c, ramap.c, random.c,
read.c, regex-posix.c, root.c, scmsigs.c, script.c, simpos.c,
socket.c, sort.c, srcprop.c, stackchk.c, stacks.c, stime.c,
strings.c, strop.c, strorder.c, strports.c, struct.c, symbols.c,
tag.c, threads.c, throw.c, unif.c, variable.c, vectors.c,
version.c, vports.c, weaks.c: Makes sure the snarfer output
inclusion is disabled when the snarfer is run on the file. Thanks
to Lars J. Aas!
* Makefile.am: Install guile-procedures.txt in version-specific
directory to enable multiple installed guile versions. Suggested
by Karl M. Hegbloom <karlheg@debian.org, patch by Matthias Koeppe.
2000-11-17 16:25:05 +00:00
|
|
|
|
#ifndef SCM_MAGIC_SNARFER
|
2000-04-21 14:16:44 +00:00
|
|
|
|
#include "libguile/list.x"
|
* alist.c, arbiters.c, async.c, backtrace.c, boolean.c, chars.c,
continuations.c, debug-malloc.c, debug.c, dynl.c, dynwind.c,
environments.c, eq.c, error.c, eval.c, evalext.c, feature.c,
filesys.c, fluids.c, fports.c, gc.c, goops.c, guardians.c, hash.c,
hashtab.c, hooks.c, ioext.c, iselect.c, keywords.c, lang.c,
list.c, load.c, macros.c, modules.c, net_db.c, numbers.c,
objects.c, objprop.c, options.c, pairs.c, ports.c, posix.c,
print.c, procprop.c, procs.c, properties.c, ramap.c, random.c,
read.c, regex-posix.c, root.c, scmsigs.c, script.c, simpos.c,
socket.c, sort.c, srcprop.c, stackchk.c, stacks.c, stime.c,
strings.c, strop.c, strorder.c, strports.c, struct.c, symbols.c,
tag.c, threads.c, throw.c, unif.c, variable.c, vectors.c,
version.c, vports.c, weaks.c: Makes sure the snarfer output
inclusion is disabled when the snarfer is run on the file. Thanks
to Lars J. Aas!
* Makefile.am: Install guile-procedures.txt in version-specific
directory to enable multiple installed guile versions. Suggested
by Karl M. Hegbloom <karlheg@debian.org, patch by Matthias Koeppe.
2000-11-17 16:25:05 +00:00
|
|
|
|
#endif
|
1996-07-25 22:56:11 +00:00
|
|
|
|
}
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|