RosettaCodeData/Task/Rot-13/SNOBOL4/rot-13.sno
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

21 lines
699 B
Text

* # Function using replace( )
define('rot13(s)u1,u2,l1,l2') :(rot13_end)
rot13 &ucase len(13) . u1 rem . u2
&lcase len(13) . l1 rem . l2
rot13 = replace(s,&ucase &lcase,u2 u1 l2 l1) :(return)
rot13_end
* # Function using pattern
define('rot13s(s)c')
alfa = &ucase &ucase &lcase &lcase :(rot13s_end)
rot13s s len(1) . c = :f(return)
alfa break(c) len(13) len(1) . c
rot13s = rot13s c :(rot13s)
rot13s_end
* # Test and display both
str = rot13("I abjure the $19.99 trinket!")
output = str; output = rot13(str)
str = rot13s("He's a real Nowhere Man.")
output = str; output = rot13s(str)
end