Tuesday, 5 March 2013
Rot13
Last week, I learned "ROT13". When a character is between A and M, we just achieve a new character that has a position by adding 13 of it in alphabet. If the character is between N and Z, we can subtract it. Likewise, if the character is not capital but lower-case character, the basic idea is still adding 13 when the character is in-between "a" and "m" or subtracting 13 when it is in-between "n" and "z". In today's class, we use Dr. Racket to operate the rule by using "cond." What is given is a string and what is produced is a new string that is "rotated" by 13. It is easy to write the rule of "ROT13", but how about reversing characters? This is not simple. Reverse-string needs to combine "string append,""sub-string," and even "reverse-string" itself. At first, we take the first left character and put it on the right by using "sub-string", then we can reverse the rest characters and put them together by using "string-append". I thought we could also reverse a list having individual characters and then use "string-append" to put them together to achieve a new string. I haven't tried this method and I am not so sure about it.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment