|
Subject: loop question - scheme help needed From: Alexander Taranov <tay@xxxxxxxxxx> Date: Tue, 8 Jun 1999 16:56:04 +0400 (MSD) |
Bas Peters writes:
> Sorry for this basic Scheme question.
>
> If have the following code:
>
> ; removes trailing punctuation for last string character
> (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))))
(define (strip-all-trailing-punctuation s)
(let loop ((s s)
(sl-1 (- (string-length s) 1)))
(if (< sl-1 0) "" ;; string contains punctuations only
(case (string-ref s sl-1)
((#\space #\: #\; #\, #\.)
(loop (substring s 0 sl-1) (- sl-1 1)))
(else s)))))
>
> (define (*extent*)
> ; Set x to the MRCB300-a content
> (let ((x
> (data (select-elements (descendants (if (equal? (gi) "MRCB300")
> (current-node)
> (ancestor "MRCB300")))
> '(MRCB300-a)))))
> (strip-trailing-punctuation x)))
>
> What I would like to do is to evaluate string -1 untill the condition is
> false. I tried to use let loop, but it seems to evaluate the string only
> once. My goal is not only to strip: "bla bla.", but also "bla bla. :"
> into "bla bla"
>
> Thanks in advance,
>
> Bas Peters
> bpeters@xxxxxx
>
>
>
>
>
> 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 | Announcement, Didier PH Martin |
| Re: loop question - scheme help nee, David Carlisle | Date | Re: loop question - scheme help nee, Alexander Taranov |
| Month |