The 'make-string-input-stream' function creates an unnamed stream from the 'string' expression. The stream can then be used as any other stream object. The optional 'start-pos' expression specifies the starting offset of the 'string' expression. A 'start-pos' of '0' will start with the beginning of the 'string'. The optional 'end-pos' expression specifies the ending offset of the 'string' expression. A 'end-pos' of 4 will make the fourth character the last in the stream. If the function is successful, it returns the unnamed stream object. If the string is empty, an unnamed stream is still returned. Error conditions include 'start-pos' and 'end-pos' being out of bounds.
(make-string-input-stream "abcdefgh") ; returns #<Unnamed-Stream: #277e2> (read (make-string-input-stream "123456")) ; returns 123456 (read (make-string-input-stream "123456" 1)) ; returns 23456 (read (make-string-input-stream "123456" 1 3)) ; returns 23 (read (make-string-input-stream "123" 0)) ; returns 123 (read (make-string-input-stream "123" 0 3)) ; returns 123 (read (make-string-input-stream "123" 2 1)) ; returns NIL (read (make-string-input-stream "123" 0 4)) ; error: string index out of bounds - 4
See the
make-string-input-stream
function in the