I find it more appropriate in a dictionary:<br><br>(define (fix2 str)<br> (for/fold ([str (string-upcase str)]) <br> ([(k v) (in-dict '((" / " . "_")<br> (" " . "_")<br>
("%" . "")<br> ("-" . "_")))])<br> (regexp-replace* k str v)))<br><br>Laurent<br><br><div class="gmail_quote">On Thu, May 10, 2012 at 11:07 PM, Vincent St-Amour <span dir="ltr"><<a href="mailto:stamourv@ccs.neu.edu" target="_blank">stamourv@ccs.neu.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Using list comprehensions:<br>
<br>
(define (fix str)<br>
(for/fold ([str str])<br>
([old '(" / " " " "%" "-")]<br>
[new '("_" "_" "" "_")])<br>
(regexp-replace* old str new)))<br>
<br>
Vincent<br>
<br>
<br>
At Thu, 10 May 2012 15:49:26 -0500,<br>
<div class="HOEnZb"><div class="h5">Grant Rettke wrote:<br>
><br>
> Using this to help out with a task at work<br>
><br>
> #lang racket<br>
><br>
> (define (fix str)<br>
> (define tmp str)<br>
> (set! tmp (regexp-replace* " / " tmp "_"))<br>
> (set! tmp (regexp-replace* " " tmp "_"))<br>
> (set! tmp (regexp-replace* "%" tmp ""))<br>
> (set! tmp (regexp-replace* "-" tmp "_"))<br>
> (string-upcase tmp))<br>
><br>
> Is there a better way?<br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br>