[racket] For new Racket users

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Aug 28 06:18:30 EDT 2011

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!



Posted on the users mailing list.