Created
March 23, 2018 16:50
-
-
Save rdavison/89f47ad5584b5a8e3d5611f854d67604 to your computer and use it in GitHub Desktop.
This file contains 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
open Printf; | |
module Unicode = Zed_utf8; | |
let isPalindrome = aString => { | |
Unicode.compare(aString, Unicode.rev(aString)) == 0 | |
}; | |
let main = { | |
let testCases = [| | |
("aoeu", false), | |
("aoeuueoa", true), | |
("racecar", true), | |
("你好", false), | |
("對不對", true) | |
|]; | |
for (i in 0 to Array.length(testCases) - 1) { | |
let (aString, expected) = testCases[i]; | |
let actual = isPalindrome(aString); | |
printf( | |
"isPalindrome(%s)?\n\ | |
\texpected - %b\n\ | |
\tactual - %b\n", | |
x, | |
expected, | |
actual | |
) | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment