Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Rot-13/MLite/rot-13.mlite
Normal file
32
Task/Rot-13/MLite/rot-13.mlite
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
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 ();
|
||||
Loading…
Add table
Add a link
Reference in a new issue