RosettaCodeData/Task/Rot-13/Standard-ML/rot-13-1.ml

10 lines
258 B
OCaml
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
fun rot13char c =
if c >= #"a" andalso c <= #"m" orelse c >= #"A" andalso c <= #"M" then
chr (ord c + 13)
else if c >= #"n" andalso c <= #"z" orelse c >= #"N" andalso c <= #"Z" then
chr (ord c - 13)
else
c
val rot13 = String.map rot13char