mes: Add string-suffix?
* module/mes/scm.mes (string-prefix?): Refactor. (string-suffix?): New function.
This commit is contained in:
parent
cd5c16cf74
commit
8f4b64fda7
|
@ -223,9 +223,18 @@
|
||||||
(list-head lst (- end start))))))
|
(list-head lst (- end start))))))
|
||||||
|
|
||||||
(define (string-prefix? prefix string)
|
(define (string-prefix? prefix string)
|
||||||
|
(let ((length (string-length string))
|
||||||
|
(prefix-length (string-length prefix)))
|
||||||
(and
|
(and
|
||||||
(>= (string-length string) (string-length prefix))
|
(>= length prefix-length)
|
||||||
(equal? (substring string 0 (string-length prefix)) prefix)))
|
(equal? (substring string 0 prefix-length) prefix))))
|
||||||
|
|
||||||
|
(define (string-suffix? suffix string)
|
||||||
|
(let ((length (string-length string))
|
||||||
|
(suffix-length (string-length suffix)))
|
||||||
|
(and
|
||||||
|
(>= length suffix-length)
|
||||||
|
(equal? (substring string (- length suffix-length)) suffix))))
|
||||||
|
|
||||||
(define (string->number s . rest)
|
(define (string->number s . rest)
|
||||||
(let* ((radix (if (null? rest) 10 (car rest)))
|
(let* ((radix (if (null? rest) 10 (car rest)))
|
||||||
|
|
Loading…
Reference in a new issue