Skip to content

Instantly share code, notes, and snippets.

@rdavison
Created March 23, 2018 16:50
Show Gist options
  • Save rdavison/89f47ad5584b5a8e3d5611f854d67604 to your computer and use it in GitHub Desktop.
Save rdavison/89f47ad5584b5a8e3d5611f854d67604 to your computer and use it in GitHub Desktop.
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