[racket] A little improvement
10 minutes ago, 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?
(define (fix str)
(string-upcase
(regexp-replace* #rx"%" (regexp-replace* #rx" / |[ -]" str "_") "")))
?
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!