schemelib/data-structures/strings.scm

19 lines
571 B
Scheme
Raw Normal View History

2020-07-02 15:35:58 +00:00
;--- String manipulation
(define (string-suffix? src suffix)
(let [(src-len (string-length src)) (suf-len (string-length suffix))]
(and
(>= src-len suf-len)
(string=? suffix (substring src (- src-len suf-len) src-len))
)))
(define (string-prefix? src prefix)
(let [(src-len (string-length src)) (pref-len (string-length prefix))]
(and
(>= src-len pref-len)
(string=? prefix (substring src 0 pref-len))
)))
(define (string-contains? src elem) ; we use port logic to implement this one
(seek-until (open-input-string src) elem))