(library (ikarus strings) (export string-ref) (import (except (ikarus) string-ref) (only (scheme) $string-ref $fx<= $fx< $string-length)) (define (string-ref s i) (unless (string? s) (error 'string-ref "~s is not a string" s)) (unless (fixnum? i) (error 'string-ref "~s is not a valid index" i)) (unless (and ($fx< i ($string-length s)) ($fx<= 0 i)) (error 'string-ref "index ~s is out of range for ~s" i s)) ($string-ref s i)))