string-ref

[procedure] string-ref string k

R5RS, R6RS: k must be a valid index of string. String-ref returns character k of string using zero-origin indexing.

In R6RS, it is noted that an implementation should make string-ref run in constant time. It is "should", so it doesn't exclude implementations that uses multibyte strings or structured strings like ropes, but such implementations should keep in mind that portable R6RS libraries may rely on the O(1) string-ref to implement some string algorithms.

R6RS has string-for-each, which would be a better choice to process a string seqentially and avoid variations in string access time.

See also string-set!.