If str ends with any of the strings in string-list, trim that string off and return the base string. E.g., (trim-string "filename.sgm" (".sgm" ".xml" ".sgml")) returns "filename".
(define (trim-string str string-list) ;; Trims the tail off of a string (let ((strlen (string-length str))) (let loop ((sl string-list)) (if (null? sl) str (if (equal? (substring str (- strlen (string-length (car sl))) strlen) (car sl)) (substring str 0 (- strlen (string-length (car sl)))) (loop (cdr sl)))))))