ikarus/src/ikarus.strings.ss

16 lines
497 B
Scheme
Raw Normal View History

2007-05-05 03:46:26 -04:00
(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)))