I find it more appropriate in a dictionary: (define (fix2 str) (for/fold ([str (string-upcase str)]) ([(k v) (in-dict '((" / " . "_") (" " . "_") ("%" . "") ("-" . "_")))]) (regexp-replace* k str v)))
Laurent On Thu, May 10, 2012 at 11:07 PM, Vincent St-Amour <stamo...@ccs.neu.edu>wrote: > 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 > ____________________ > Racket Users list: > http://lists.racket-lang.org/users >
____________________ Racket Users list: http://lists.racket-lang.org/users