Re: loop question - scheme help needed

Subject: Re: loop question - scheme help needed
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 8 Jun 1999 13:15:48 +0100 (BST)


(define (strip-trailing-punctuation s)
  (let ((sl-1 (- (string-length s) 1)))
    (case (string-ref s sl-1)
      ((#\space #\: #\; #\, #\.) (substring s 0 sl-1))
                                 ;;;;;;;;;;;;;;;;;;;;
      (else s))))

this says if you find the punctuation remove it, otherwise return the
string. 

What you want to do is

 if you find the punctuation remove it, and recursively look for some
more punctuation,  otherwise return the string. 

(define (strip-trailing-punctuation s)
  (let ((sl-1 (- (string-length s) 1)))
    (case (string-ref s sl-1)
      ((#\space #\: #\; #\, #\.) (strip-trailing-punctuation(substring s 0 sl-1)))
                                 ;;;;;;;;;;;;;;;;;;;;
      (else s))))


David
(not tested:-)


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread