Skip to content

Instantly share code, notes, and snippets.

@3tty0n
Created August 8, 2019 08:27
Show Gist options
  • Select an option

  • Save 3tty0n/e92032990c3a6fd68e54cbee524070b2 to your computer and use it in GitHub Desktop.

Select an option

Save 3tty0n/e92032990c3a6fd68e54cbee524070b2 to your computer and use it in GitHub Desktop.
type msg = int list
type key = int
let string_of_msg msg =
msg |> List.map (fun x -> string_of_int x) |> String.concat ""
let rot key msg =
msg |> List.map begin fun x ->
(x + key) mod 26
end
let () =
let msg = [1; 2; 3; 14; 13; 12] in
assert (
let x = rot 3 msg in
msg = rot (-3) x);
rot 3 msg |> string_of_msg |> print_endline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment