[racket] For new Racket users

From: Joan Arnaldich (jarnaldich at gmail.com)
Date: Sun Aug 28 07:18:32 EDT 2011

Eli Barzilay <eli at ...> writes:

> (define (translate str)
>   (define A (char->integer #\a))
>   (define (rotate x) (+ A (modulo (- x A -2) 26)))
>   (regexp-replace* #rx#"[a-z]" str (λ (m) (bytes (rotate (bytes-ref m 0))))))

That's definitely better. Hadn't read the docs for regexp-replace
close enough... hope you don't mind if I paste this into the challenge
wiki? 

> In any case, it's easy to write some tr-style utility, the question is
> whether it has any practical use.  (I've seen a number, they were all
> from such toys.)
 
I don't think a tr library would be that useful if you
can just pass a lambda to regexp-replace...






Posted on the users mailing list.