On 13/02/16 01:32, Segher Boessenkool wrote:
Let's factor this a bit better...
: rot13 ( c - c ) dup upc [char] A [char] M between IF d# 13 + EXIT THEN dup upc [char] N [char] Z between IF d# 13 - THEN ;
: $rot13 ( str len -- ) bounds ?DO i c@ rot13 i c! LOOP ;
: rot13-str ( str len -- newstr len ) strdup 2dup $rot13 ;
Hope I didn't mess this up ;-)
Yeah, your Forth is obviously much better then mine ;) Thanks for this, I'll include it in the next revision of the copyright patchset (albeit with a few minor cosmetic tweaks).
ATB,
Mark.