rot13 in pure newlisp no regex(p)

Started by newdep, March 03, 2004, 02:47:02 PM

Previous topic - Next topic

Sammo

#15
(context 'rot13)

(define (rot13:aux ch , i)
  (if (set 'i (find ch "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"))
    ("nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" i)
    ch ))

(define (rot13:rot13 str)
  (join (map rot13:aux (explode str))) )

(context 'MAIN)

> (silent (setq s (read-file "newlisp-tk.html")))

> (length s)

82220

> (time (rot13 s))

420

newdep

#16
You got the time record ;-) Seems mapping is quick and even quicker with a  predefined map list ;-) Nice routine!



Norman.
-- (define? (Cornflakes))