1 ! Copyright (C) 2006 Daniel Ehrenberg
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel math sequences strings io combinators ascii ;
6 : rotate ( ch base -- ch ) tuck - 13 + 26 mod + ;
8 : rot-letter ( ch -- ch )
10 { [ dup letter? ] [ CHAR: a rotate ] }
11 { [ dup LETTER? ] [ CHAR: A rotate ] }
15 : rot13 ( string -- string ) [ rot-letter ] map ;
18 "Please enter a string:" print flush
20 "Your string: " write dup print
21 "Rot13: " write rot13 print