ceasar.scm 580 B

12345678910111213141516171819
  1. (define msg "The quick brown fox jumps over the lazy dog.")
  2. (define key 13)
  3. (define (caesar char)
  4. (let* ((a* (char->integer #\A))
  5. (z* (char->integer #\Z))
  6. (a (char->integer #\a))
  7. (z (char->integer #\z))
  8. (c (char->integer char)))
  9. (integer->char
  10. (if (if (<= a* c) (<= c z*) #f)
  11. (+ a* (modulo (+ key (- c a*)) 26))
  12. (if (if (<= a c) (<= c z) #f)
  13. (+ a (modulo (+ key (- c a)) 26))
  14. c))))) ; Return other characters verbatim.
  15. (define t1 (print (list->string (map caesar (string->list msg)))))