#| -*-Scheme-*-
-$Id: string.scm,v 14.17 1999/01/02 06:19:10 cph Exp $
+$Id: string.scm,v 14.18 1999/04/07 04:05:07 cph Exp $
Copyright (c) 1988-1999 Massachusetts Institute of Technology
(list->string chars))
(define char->string string)
-
+\f
(define (string->list string)
(guarantee-string string 'STRING->LIST)
(%substring->list string 0 (string-length string)))
(define (string-append . strings)
(%string-append strings))
+
+(define (burst-string string delimiter)
+ (let ((end (string-length string)))
+ (let loop ((start 0) (index 0) (result '()))
+ (cond ((fix:= index end)
+ (reverse!
+ (if (fix:< start index)
+ (cons (substring string start index) result)
+ result)))
+ ((char=? delimiter (string-ref string index))
+ (loop (fix:+ index 1)
+ (fix:+ index 1)
+ (if (fix:< start index)
+ (cons (substring string start index) result)
+ result)))
+ (else
+ (loop start (fix:+ index 1) result))))))
\f
;;;; Case
(substring-fill! result 0 i char))
(substring-move-right! string 0 length result i)))
result))))
+\f
+;;;; String Search
+
+;;; This is the obvious dumb implementation. Boyer-Moore is planned
+;;; for the future.
(define (substring? substring string)
;; Returns starting-position or #f if not true.
(if (not (fix:<= end (string-length string)))
(error:bad-range-argument end procedure))
(if (not (fix:<= start end))
- (error:bad-range-argument start procedure)))
+ (error:bad-range-argument start procedure)))
\ No newline at end of file