Advertisement
Ethangx8

zzzz

Jul 7th, 2020
2,794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.71 KB | None | 0 0
  1. (define alph '(#\A #\B #\C #\D #\E #\F #\G #\H #\I #\L #\M #\N #\O #\P #\Q #\R #\S #\T #\V #\X))
  2.  
  3. (define getPos
  4.   (lambda (list c p)
  5.     (cond ((null? list) -1)
  6.           ((char=? c (car list)) p)
  7.           (else (getPos (cdr list) c (+ p 1)))
  8.           )
  9.     )
  10.   )
  11. (define crypt-f
  12.   (lambda (c n)
  13.       (let ((t (+ n (getPos alph c 0))))
  14.             (list-ref alph (remainder t 20)))
  15.         )
  16.  )
  17. (define crypt-t
  18.   (lambda (n s)
  19.     (if (string=? s "")
  20.         ""
  21.         (string-append (if (char=? (string-ref s 0) #\space) "" (string (crypt-f (string-ref s 0) n))) (crypt-t n (substring s 1)))
  22.         )
  23.     )
  24.   )
  25. (define caesar
  26.   (lambda (n)
  27.    (lambda (s)
  28.      (crypt-t n s)
  29.      )
  30.     )
  31.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement