sunet/doc/stringhax.scm.doc

79 lines
2.0 KiB
Plaintext

This file documents names specified in stringhax.scm.
NOTES
stringhax.scm provides several string-hacking procedures.
DEFINITIONS AND DESCRIPTIONS
procedure
string-map procedure string --> string
Does a 'map' on each character of STRING and returns the result, a
newly allocated string. PROCEDURE takes a character and should return
a character.
procedure
downcase-string string --> string
upcase-string string --> string
Do what you expect: converts STRING to downcase or upcase
respectively, using char-downcase or char-upcase respectively. The
result is a newly allocated string.
procedure
char-set-index string char-set [start] --> number
char-set-rindex string char-set [start] --> number
Returns the index of the first character that is in
char-set. char-set-index searches from left to r0.6/scsh/lib/char-package.scmight, char-set-rindex
from right to left. START is the index from where to start from and
defaults to 0 in char-set-index and (string-length STRING) in
char-set-rindex. If the search fails, #f is returned.
procedure
string-reduce default construct string --> string
Does a "fold-right" on string. The resulting string is
(CONSTRUCT ... (CONSTRUCT STRING[n-1] (CONSTRUCT STRING[n] DEFAULT)) ...)
Example:
(string-reduce "" (lambda (char str)
(string-append str (string (char-downcase char))))
"DOWNCASE")
==> "downcase"
procedure
string-prefix? prefix string --> boolean
string-suffix? suffix string --> boolean
Return #t if PREFIX/SUFFIX is a real prefix/suffix of STRING,
otherwise return #f. Real prefix/suffix means that STRING may not be a
prefix/suffix of PREFIX/SUFFIX.
procedure
skip-whitespace string --> number
Returns the index of the first character in STRING that is not a
whitespace (as defined in char-set:whitespace). If there isn't such a
character, #f is returned.
procedure
trim-spaces string --> string
Returns a newly allocated string being STRING without leading or
trailing spaces (not whitespaces!).