mes: Add string-rindex.
* module/srfi/srfi-13.mes (string-rindex): New function.
This commit is contained in:
parent
20b3c349bf
commit
dda7a7cd62
|
@ -74,3 +74,14 @@
|
|||
(if (null? lst) #f
|
||||
(if (pred (car lst)) i
|
||||
(loop (cdr lst) (1+ i)))))))
|
||||
|
||||
(define (string-rindex s pred . rest)
|
||||
(let* ((start (and (pair? rest) (car rest)))
|
||||
(end (and start (pair? (cdr rest)) (cadr rest)))
|
||||
(pred (if (char? pred) (lambda (c) (eq? c pred)) pred)))
|
||||
(if start (error "string-rindex: not supported: start=" start))
|
||||
(if end (error "string-rindex: not supported: end=" end))
|
||||
(let loop ((lst (reverse (string->list s))) (i (1- (string-length s))))
|
||||
(if (null? lst) #f
|
||||
(if (pred (car lst)) i
|
||||
(loop (cdr lst) (1- i)))))))
|
||||
|
|
Loading…
Reference in a new issue