[REBOL] Pleac/rot13
From: Rebolinth:nodep:dds:nl at: 12-Oct-2003 13:42
Hello Karl Robillard (krobillard),
Your Version is very Small but not a fully ROT13!
Rot13 may only convert a - z A - Z
Your version also converts anyother character (byte) too, so it wont work on binary strings..
This though works fine in a foreach loop (below), I believe it can be smaller,
but i could not manage it to get it smaller after headbreaking ;-)
rot13: func [ char [char!] { returns a rotate 13 on alphanumeric charatcers } ] [
char: to-char char
if any [ all [ char >= #"a" char <= #"m" ] all [ char >= #"A" char <= #"M" ] ] [ return
char + 13 ]
if any [ all [ char >= #"n" char <= #"z" ] all [ char >= #"N" char <= #"Z" ] ] [ return
char - 13 ]
return char
]
(R)egards, Norman.
--
Conversation/lunch: "How do you Eat your Rebol in the Morning?"