| string->list(3scm) | Scheme Programmer's Manual | string->list(3scm) |
NAME
string->list, list->string - convert between strings and listsLIBRARY
(import (rnrs)) ;R6RS (import (rnrs base)) ;R6RS (import (scheme r5rs)) ;R7RS (import (scheme base)) ;R7RS
SYNOPSIS
(string->list string) (string->list string start) ;R7RS (string->list string start end) ;R7RS (list->string list)
DESCRIPTION
The string->list procedure returns a newly allocated list of the characters that make up the given string.The list->string procedure returns a newly allocated string formed from the characters in list.
These procedures are inverses so far as equal?(3string) is concerned, and preserve the order of the characters.
- R7RS
- The string->list procedure returns a newly allocated list of the characters of string between start (inclusive) and end (exclusive).
IMPLEMENTATION NOTES
Some implementations have a single empty string object; see make-string(3scm).RETURN VALUES
Both of these procedures return a single value. The string->list procedure returns a list (a pair or the empty list); the list->string procedure returns a string object.EXAMPLES
(string->list "Quux") => (#\Q #\u #\u #\x) (list->string '(#\f #\o #\o)) => "foo"
APPLICATION USAGE
These procedures can be seen in some highly functional programming styles.COMPATIBILITY
The start and end arguments are unique to R7RS. The only other difference between implementations is whether the empty string is newly allocated or not (see above).ERRORS
This procedure can raise exceptions with the following condition types:- &assertion (R6RS)
- The wrong number of arguments was passed or an argument was outside its domain. In particular, list must be a list of characters and string must be a string.
- R7RS
- The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.
- Unsupported characters (R7RS)
- It is an error for the list passed to list->string to contain a character which the implementation does not support. 7-bit ASCII (except #\null) must be supported. Any other character is optional and potentially an error (as described above). You can use the full-unicode feature identifier in cond-expand(3scm) to check if all of Unicode 6.0 is supported.
SEE ALSO
list->vector(3scm), string-append(3scm)STANDARDS
R4RS, R5RS, R6RS, R7RSHISTORY
These procedures first appeared in R2RS. They are missing from IEEE Scheme.AUTHORS
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.| 2022-05-12 |