Subject: Re: loop question - scheme help needed From: Alexander Taranov <tay@xxxxxxxxxx> Date: Tue, 8 Jun 1999 16:58:27 +0400 (MSD) |
David Carlisle writes: > > > > (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:-) You need also handle a case with punctuations only like "....." > > > DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist > DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: loop question - scheme help nee, David Carlisle | Thread | Re: loop question - scheme help nee, David Carlisle |
loop question - scheme help needed, Alexander Taranov | Date | Re: loop question - scheme help nee, David Carlisle |
Month |