33 lines
804 B
Plaintext
33 lines
804 B
Plaintext
fun readfile () = readfile []
|
|
| x = let val ln = readln ()
|
|
in if eof ln then
|
|
rev x
|
|
else
|
|
readfile ` ln :: x
|
|
end
|
|
|
|
local
|
|
val lower_z = ord #"z";
|
|
val upper_z = ord #"Z";
|
|
val lower_a = ord #"a";
|
|
val upper_a = ord #"A";
|
|
|
|
fun which
|
|
(c_upper c) = (upper_a, upper_z)
|
|
| _ = (lower_a, lower_z)
|
|
;
|
|
|
|
fun scale
|
|
(c, az) where (c > #1 az) = scale( (#0 az + (c - #1 az - 1)), az)
|
|
| (c, az) = c
|
|
|
|
in
|
|
fun rot13
|
|
([], t) = implode ` rev t
|
|
| (x :: xs, t) where (c_alphabetic x) = rot13 (xs, (chr ` scale (ord x + 13, which x)) :: t)
|
|
| (x :: xs, t) = rot13 (xs, x :: t)
|
|
| s = rot13 (explode s, [])
|
|
end;
|
|
|
|
map (println o rot13) ` readfile ();
|