Next: strings replicate, Previous: strings filter, Up: strings [Index]
Return a newly allocated list of the characters that make up the given
substring. This is an extension of the string->list
function
that adds support for substrings.
Like %string->list*
but reverses the order of the characters from
the substring.
Reverse the given list of characters, then compose a string with the result.
(reverse-list->string '(#\a #\B #\c)) ⇒ "cBa"
Split the selected substring into a list of strings, where each string is a maximal, non–empty, contiguous sequence of characters from the character set token-set.
(string-tokenize "Help make programs run, run, RUN!" (char-set-complement (char-set #\space) char-set:ascii)) ⇒ ("Help" "make" "programs" "run," "run," "RUN!")
This function provides a minimal parsing facility for simple applications. More sophisticated parsers that handle quoting and backslash effects can easily be constructed using regular–expression systems; be careful not to use
string-tokenize
in contexts where more serious parsing is needed.
This procedure is a simple unparser: It pastes strings together using
the delimiter string. delimiter defaults to a single white
space. grammar is a symbol that determines how the delimiter is
used, and defaults to infix
. Supported values for grammar
are:
infix
Means an infix or separator grammar: Insert the delimiter between list elements. An empty list will produce an empty string.
Note: Parsing an empty string with an infix grammar is ambiguous. Is it an empty list, or a list of one element, the empty string?
strict-infix
Means the same as infix
, but will raise an error if given an
empty list.
suffix
Means a suffix or terminator grammar: Insert the delimiter after every list element. This grammar has no ambiguities.
prefix
Means a prefix grammar: Insert the delimiter before every list element. This grammar has no ambiguities.
The delimiter is the string used to delimit elements; it defaults to a single space.
Examples:
(string-join '("foo" "bar" "baz") ":") ⇒ "foo:bar:baz" (string-join '("foo" "bar" "baz") ":" 'suffix) ⇒ "foo:bar:baz:" ;; Infix grammar is ambiguous wrt empty list vs. empty string, (string-join '() ":") ⇒ "" (string-join '("") ":") ⇒ "" (string-join '("") "," 'strict-infix) ⇒ "" (string-join '("") "," 'suffix) ⇒ "," (string-join '("") "," 'prefix) ⇒ ","
Next: strings replicate, Previous: strings filter, Up: strings [Index]