27 |
@section Pairs |
@section Pairs |
28 |
@tpindex Pairs |
@tpindex Pairs |
29 |
|
|
|
@c FIXME::martin: Review me! |
|
|
|
|
30 |
Pairs are used to combine two Scheme objects into one compound object. |
Pairs are used to combine two Scheme objects into one compound object. |
31 |
Hence the name: A pair stores a pair of objects. |
Hence the name: A pair stores a pair of objects. |
32 |
|
|
131 |
@section Lists |
@section Lists |
132 |
@tpindex Lists |
@tpindex Lists |
133 |
|
|
|
@c FIXME::martin: Review me! |
|
|
|
|
134 |
A very important data type in Scheme---as well as in all other Lisp |
A very important data type in Scheme---as well as in all other Lisp |
135 |
dialects---is the data type @dfn{list}.@footnote{Strictly speaking, |
dialects---is the data type @dfn{list}.@footnote{Strictly speaking, |
136 |
Scheme does not have a real datatype @dfn{list}. Lists are made up of |
Scheme does not have a real datatype @dfn{list}. Lists are made up of |
169 |
@node List Syntax |
@node List Syntax |
170 |
@subsection List Read Syntax |
@subsection List Read Syntax |
171 |
|
|
|
@c FIXME::martin: Review me! |
|
|
|
|
172 |
The syntax for lists is an opening parentheses, then all the elements of |
The syntax for lists is an opening parentheses, then all the elements of |
173 |
the list (separated by whitespace) and finally a closing |
the list (separated by whitespace) and finally a closing |
174 |
parentheses.@footnote{Note that there is no separation character between |
parentheses.@footnote{Note that there is no separation character between |
202 |
@node List Predicates |
@node List Predicates |
203 |
@subsection List Predicates |
@subsection List Predicates |
204 |
|
|
|
@c FIXME::martin: Review me! |
|
|
|
|
205 |
Often it is useful to test whether a given Scheme object is a list or |
Often it is useful to test whether a given Scheme object is a list or |
206 |
not. List-processing procedures could use this information to test |
not. List-processing procedures could use this information to test |
207 |
whether their input is valid, or they could do different things |
whether their input is valid, or they could do different things |
271 |
@node List Selection |
@node List Selection |
272 |
@subsection List Selection |
@subsection List Selection |
273 |
|
|
|
@c FIXME::martin: Review me! |
|
|
|
|
274 |
These procedures are used to get some information about a list, or to |
These procedures are used to get some information about a list, or to |
275 |
retrieve one or more elements of a list. |
retrieve one or more elements of a list. |
276 |
|
|
313 |
@node Append/Reverse |
@node Append/Reverse |
314 |
@subsection Append and Reverse |
@subsection Append and Reverse |
315 |
|
|
|
@c FIXME::martin: Review me! |
|
|
|
|
316 |
@code{append} and @code{append!} are used to concatenate two or more |
@code{append} and @code{append!} are used to concatenate two or more |
317 |
lists in order to form a new list. @code{reverse} and @code{reverse!} |
lists in order to form a new list. @code{reverse} and @code{reverse!} |
318 |
return lists with the same elements as their arguments, but in reverse |
return lists with the same elements as their arguments, but in reverse |
451 |
@node List Searching |
@node List Searching |
452 |
@subsection List Searching |
@subsection List Searching |
453 |
|
|
|
@c FIXME::martin: Review me! |
|
|
|
|
454 |
The following procedures search lists for particular elements. They use |
The following procedures search lists for particular elements. They use |
455 |
different comparison predicates for comparing list elements with the |
different comparison predicates for comparing list elements with the |
456 |
object to be searched. When they fail, they return @code{#f}, otherwise |
object to be searched. When they fail, they return @code{#f}, otherwise |
490 |
empty list) is returned. |
empty list) is returned. |
491 |
@end deffn |
@end deffn |
492 |
|
|
|
[FIXME: Is there any reason to have the `sloppy' functions available at |
|
|
high level at all? Maybe these docs should be relegated to a "Guile |
|
|
Internals" node or something. -twp] |
|
|
|
|
|
@deffn {Scheme Procedure} sloppy-memq x lst |
|
|
This procedure behaves like @code{memq}, but does no type or error checking. |
|
|
Its use is recommended only in writing Guile internals, |
|
|
not for high-level Scheme programs. |
|
|
@end deffn |
|
|
|
|
|
@deffn {Scheme Procedure} sloppy-memv x lst |
|
|
This procedure behaves like @code{memv}, but does no type or error checking. |
|
|
Its use is recommended only in writing Guile internals, |
|
|
not for high-level Scheme programs. |
|
|
@end deffn |
|
|
|
|
|
@deffn {Scheme Procedure} sloppy-member x lst |
|
|
This procedure behaves like @code{member}, but does no type or error checking. |
|
|
Its use is recommended only in writing Guile internals, |
|
|
not for high-level Scheme programs. |
|
|
@end deffn |
|
493 |
|
|
494 |
@node List Mapping |
@node List Mapping |
495 |
@subsection List Mapping |
@subsection List Mapping |
496 |
|
|
|
@c FIXME::martin: Review me! |
|
|
|
|
497 |
List processing is very convenient in Scheme because the process of |
List processing is very convenient in Scheme because the process of |
498 |
iterating over the elements of a list can be highly abstracted. The |
iterating over the elements of a list can be highly abstracted. The |
499 |
procedures in this section are the most basic iterating procedures for |
procedures in this section are the most basic iterating procedures for |
856 |
created with this type of field, the field is initialized to refer to |
created with this type of field, the field is initialized to refer to |
857 |
the structure's own handle. This kind of field is mainly useful when |
the structure's own handle. This kind of field is mainly useful when |
858 |
mixing Scheme and C code in which the C code may need to compute a |
mixing Scheme and C code in which the C code may need to compute a |
859 |
structure's handle given only the address of its malloc-ed data. |
structure's handle given only the address of its malloc'd data. |
860 |
@end itemize |
@end itemize |
861 |
|
|
862 |
|
|
1676 |
procedures for manipulating them. |
procedures for manipulating them. |
1677 |
|
|
1678 |
@menu |
@menu |
1679 |
* Alist Key Equality:: |
* Alist Key Equality:: |
1680 |
* Adding or Setting Alist Entries:: |
* Adding or Setting Alist Entries:: |
1681 |
* Retrieving Alist Entries:: |
* Retrieving Alist Entries:: |
1682 |
* Removing Alist Entries:: |
* Removing Alist Entries:: |
1683 |
* Sloppy Alist Functions:: |
* Sloppy Alist Functions:: |
1684 |
* Alist Example:: |
* Alist Example:: |
1685 |
@end menu |
@end menu |
1686 |
|
|
1687 |
@node Alist Key Equality |
@node Alist Key Equality |
1688 |
@subsubsection Alist Key Equality |
@subsubsection Alist Key Equality |
1689 |
|
|
1690 |
All of Guile's dedicated association list procedures, apart from |
All of Guile's dedicated association list procedures, apart from |
1691 |
@code{acons}, come in three flavors, depending on the level of equality |
@code{acons}, come in three flavours, depending on the level of equality |
1692 |
that is required to decide whether an existing key in the association |
that is required to decide whether an existing key in the association |
1693 |
list is the same as the key that the procedure call uses to identify the |
list is the same as the key that the procedure call uses to identify the |
1694 |
required entry. |
required entry. |
1827 |
@deffnx {C Function} scm_assq_set_x (alist, key, val) |
@deffnx {C Function} scm_assq_set_x (alist, key, val) |
1828 |
@deffnx {C Function} scm_assv_set_x (alist, key, val) |
@deffnx {C Function} scm_assv_set_x (alist, key, val) |
1829 |
@deffnx {C Function} scm_assoc_set_x (alist, key, val) |
@deffnx {C Function} scm_assoc_set_x (alist, key, val) |
1830 |
Re-associate @var{key} in @var{alist} with @var{value}: find any existing |
Reassociate @var{key} in @var{alist} with @var{value}: find any existing |
1831 |
@var{alist} entry for @var{key} and associate it with the new |
@var{alist} entry for @var{key} and associate it with the new |
1832 |
@var{value}. If @var{alist} does not contain an entry for @var{key}, |
@var{value}. If @var{alist} does not contain an entry for @var{key}, |
1833 |
add a new one. Return the (possibly new) alist. |
add a new one. Return the (possibly new) alist. |