diff options
Diffstat (limited to 'guile')
-rw-r--r-- | guile/rot-13.scm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/guile/rot-13.scm b/guile/rot-13.scm index 1a32e50..15c9405 100644 --- a/guile/rot-13.scm +++ b/guile/rot-13.scm @@ -18,9 +18,10 @@ ;;;; GNU Anubis is released under the GPL with the additional exemption that ;;;; compiling, linking, and/or using OpenSSL is allowed. -(define (rot-13 text) +(define (rot-13-text input) "Encode the text using ROT-13 method" - (let ((length (string-length text))) + (let* ((text (string-append "" input)) + (length (string-length text))) (do ((i 0 (1+ i))) ((>= i length) text) (let ((c (string-ref text i))) @@ -34,3 +35,18 @@ (integer->char (+ 65 (modulo (+ (- (char->integer c) 65) 13) 26)))))))))) +(define (rot-13 hdr body . rest) + (let ((rs (lambda (h) + (map (lambda (x) + (if (string-ci=? (car x) "subject") + (cons (car x) (rot-13-text (cdr x))) + x)) + h)))) + (if (null? rest) + (cons (rs hdr) (rot-13-text body)) + (cons (if (member #:subject rest) + (rs hdr) + #t) + (if (member #:body rest) + (rot-13-text body) + #t))))) |