Skip to content

Instantly share code, notes, and snippets.

@arsatiki
Created September 4, 2012 12:48
Show Gist options
  • Save arsatiki/3620873 to your computer and use it in GitHub Desktop.
Save arsatiki/3620873 to your computer and use it in GitHub Desktop.
Excercise 4.3
let translate = function
'A' -> 'C' | 'B' -> 'A' | 'C' -> 'D' | 'D' -> 'B'
| _ -> invalid_arg "Not a plaintext string";;
let stringtail s =
String.sub s 1 (String.length s - 1);;
let rec check s1 s2 =
match (s1, s2) with
("", "") -> true
| ("", _) -> false
| (_, "") -> false
| _ -> if translate s1.[0] = s2.[0] then
check (stringtail s1) (stringtail s2)
else false;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment