Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: pleac

From: carl:cybercraft at: 24-Dec-2003 22:39

On 12-Oct-03, Karl Robillard wrote:
> I followed a link off the Pleac site to the ROT13 implementation > page (http://www.miranda.org/~jkominek/rot13/). The REBOL version > posted there is unbelievably bad! It's so bad that I suspect it was > sent in as a joke. I sent the webmaster the version below. I just > hope the site is still being maintained. I'd hate for someone to > think REBOL is so cumbersome. > REBOL[] > foreach c input [ > cap: c and 32 > c: c and complement cap > if (c >= #"A") and (c <= #"Z") [ > c: c - #"A" + 13 // 26 + #"A" > ] > prin to-char c or cap > ] > prin "^/"
I got wondering if REBOL's case-insensitivity could be put to good use with this problem, and came up with the following. Not much difference in code-size to your approach, but different-looking, anyway... rebol [] text: input forall text [ letter: to-string text/1 if all [letter >= "a" letter <= "z"][ text/1: text/1 + either letter < "n" [13][-13] ] ] text: head text print text -- Carl Read