Greetings,
Recently, I was working on something that just wouldn't work
properly. Rather than get frustrated, I decided to get a chuckle from
the offensive fortunes through cookie(). I discovered to my dismay
that the offensive fortunes are rot13 encoded. As a result, I wrote the
following functions and figured I would submit them if they prove
amusing/useful in any way.
Have a nice evening,
-Trey
(defun rot13 (string)
"Rot13 a string"
(rot string 13))
(defun rot (my-str num)
"Rotate a string by num characters, if num is greater than 26, bad
things may happen"
;; result has one character concatenated to it for every iteration of mapcar
(let ((result ""))
(concat result
;; mapcar takes two arguments, a function and sequence, the sequence is
;; the list of characters which makes up the given string
;; the function in this case is the following anonymous lambda form.
(mapcar
(function
(lambda (char)
(cond
((and (< char 123) (> char 96)) ;; lowercase characters
(if (> char (- 122 num))
(int-to-char (- char (- 26 num)))
(int-to-char (+ char num))))
((and (< char 91) (> char 64)) ;; uppercase characters
(if (> char (- 90 num))
(int-to-char (- char (- 26 num)))
(int-to-char (+ char num))))
(t
char))))
(string-to-list my-str)))))
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ashton Trey Belew
Phone: 860 983 1046
e-mail: trey(a)veggie.wesleyan.edu
http://veggie.wesleyan.edu/trey/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I shot a query into the net.
I haven't got an answer yet, A posted message called me rotten
But seven people gave me hell For ignoring mail I'd never gotten;
And said I ought to learn to spell; An angry message asked me, Please
Don't send such drivel overseas;
A lawyer sent me private mail
And swore he'd slap my ass in jail -- One netter thought it was a hoax:
I'd mentioned Un*x in my gem "Hereafter, post to net dot jokes!";
And failed to add the T and M; Another called my grammar vile
And criticized my writing style.
Each day I scan each Subject line
In hopes the topic will be mine;
I shot a query into the net.
I haven't got an answer yet...
-- Ed Nather