[racket] A little improvement
Using list comprehensions:
(define (fix str)
(for/fold ([str str])
([old '(" / " " " "%" "-")]
[new '("_" "_" "" "_")])
(regexp-replace* old str new)))
Vincent
At Thu, 10 May 2012 15:49:26 -0500,
Grant Rettke wrote:
>
> Using this to help out with a task at work
>
> #lang racket
>
> (define (fix str)
> (define tmp str)
> (set! tmp (regexp-replace* " / " tmp "_"))
> (set! tmp (regexp-replace* " " tmp "_"))
> (set! tmp (regexp-replace* "%" tmp ""))
> (set! tmp (regexp-replace* "-" tmp "_"))
> (string-upcase tmp))
>
> Is there a better way?
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users