[racket] For new Racket users

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Aug 28 07:37:25 EDT 2011

You can also use for/string to make a pretty compact version.

Robby

On Sun, Aug 28, 2011 at 5:18 AM, Eli Barzilay <eli at barzilay.org> wrote:
> 40 minutes ago, Joan Arnaldich wrote:
>> level 2 will always be ugly without the Python maketrans function. I
>> used a hash: https://gist.github.com/3151724e7ac74264c52e.
>
> Here's another:
>
> (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))))))
>
> 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.)
>
> --
>          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                    http://barzilay.org/                   Maze is Life!
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users



Posted on the users mailing list.