Created
August 8, 2019 08:27
-
-
Save 3tty0n/e92032990c3a6fd68e54cbee524070b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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