mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 13:00:26 +02:00
(SRFI-13 Predicates): Add string-any and
string-every support for char and charset predicates.
This commit is contained in:
parent
dcb5d76ba3
commit
f0ab0c5db1
1 changed files with 55 additions and 12 deletions
|
@ -1197,20 +1197,59 @@ In addition to the primitives @code{string?} and @code{string-null?},
|
||||||
which are already in the Guile core, the string predicates
|
which are already in the Guile core, the string predicates
|
||||||
@code{string-any} and @code{string-every} are defined by SRFI-13.
|
@code{string-any} and @code{string-every} are defined by SRFI-13.
|
||||||
|
|
||||||
@deffn {Scheme Procedure} string-any pred s [start end]
|
@deffn {Scheme Procedure} string-any char_pred s [start end]
|
||||||
Check if the predicate @var{pred} is true for any character in
|
Return true if @code{char_pred} is satisfied for any character in the
|
||||||
the string @var{s}, proceeding from left (index @var{start}) to
|
string @var{s}. @var{char_pred} can be
|
||||||
right (index @var{end}). If @code{string-any} returns true,
|
|
||||||
the returned true value is the one produced by the first
|
@itemize @bullet
|
||||||
successful application of @var{pred}.
|
@item
|
||||||
|
A character, to to test for any in @var{s} equal to that.
|
||||||
|
@item
|
||||||
|
A character set (@pxref{SRFI-14}), to test for any character in
|
||||||
|
@var{s} in that character set.
|
||||||
|
@item
|
||||||
|
A predicate function, called as @code{(@var{char_pred} c)} for each
|
||||||
|
character in @var{s}, from left to right, to test for any on which
|
||||||
|
@var{char_pred} returns true.
|
||||||
|
|
||||||
|
When @var{char_pred} does return true (ie.@: non-@code{#f}), that
|
||||||
|
value is the value returned by @code{string-any}.
|
||||||
|
@end itemize
|
||||||
|
|
||||||
|
If there are no characters in @var{s} (ie.@: @var{start} equals
|
||||||
|
@var{end}) then the return is @code{#f}.
|
||||||
|
|
||||||
|
SRFI-13 specifies that when @var{char_pred} is a predicate function,
|
||||||
|
the call on the last character of @var{s} (assuming that point is
|
||||||
|
reached) is a tail call, but currently in Guile this is not the case.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Scheme Procedure} string-every pred s [start end]
|
@deffn {Scheme Procedure} string-every char_pred s [start end]
|
||||||
Check if the predicate @var{pred} is true for every character
|
Return true if @var{char_pred} is satisifed for every character in the
|
||||||
in the string @var{s}, proceeding from left (index @var{start})
|
string @var{s}. @var{char_pred} can be
|
||||||
to right (index @var{end}). If @code{string-every} returns
|
|
||||||
true, the returned true value is the one produced by the final
|
@itemize @bullet
|
||||||
application of @var{pred} to the last character of @var{s}.
|
@item
|
||||||
|
A character, to to test for every character in @var{s} equal to that.
|
||||||
|
@item
|
||||||
|
A character set (@pxref{SRFI-14}), to test for every character in
|
||||||
|
@var{s} being in that character set.
|
||||||
|
@item
|
||||||
|
A predicate function, called as @code{(@var{char_pred} c)} for each
|
||||||
|
character in @var{s}, from left to right, to test that it returns true
|
||||||
|
for every character in @var{s}.
|
||||||
|
|
||||||
|
When @var{char_pred} does return true (ie.@: non-@code{#f}) for every
|
||||||
|
character, the return from the last call is the value returned by
|
||||||
|
@code{string-every}.
|
||||||
|
@end itemize
|
||||||
|
|
||||||
|
If there are no characters in @var{s} (ie.@: @var{start} equals
|
||||||
|
@var{end}) then the return is @code{#t}.
|
||||||
|
|
||||||
|
SRFI-13 specifies that when @var{char_pred} is a predicate function,
|
||||||
|
the call on the last character of @var{s} (assuming that point is
|
||||||
|
reached) is a tail call, but currently in Guile this is not the case.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
|
||||||
|
@ -2431,3 +2470,7 @@ The second syntax can be used to create anonymous recursive functions:
|
||||||
424242
|
424242
|
||||||
guile>
|
guile>
|
||||||
@end lisp
|
@end lisp
|
||||||
|
|
||||||
|
@c Local Variables:
|
||||||
|
@c TeX-master: "guile.texi"
|
||||||
|
@c End:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue