fun readfile () = readfile [] | x = let val ln = readln () in if eof ln then rev x else readfile ` ln :: x end local val lower_a = ord #"a"; val lower_z = ord #"z"; val upper_a = ord #"A"; val upper_z = ord #"Z"; 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 encipher ([], offset, t) = implode ` rev t | (x :: xs, offset, t) where (c_alphabetic x) = encipher (xs, offset, (chr ` scale (ord x + offset, which x)) :: t) | (x :: xs, offset, t) = encipher (xs, offset, x :: t) | (s, offset) = if (offset < 0) then encipher (explode s, 26 + (offset rem 26), []) else encipher (explode s, offset rem 26, []) end fun default (false, y) = y | (x, _) = x ; map println ` map (fn s = encipher (s,ston ` default (argv 0, "1"))) ` readfile ();