Skip to content

Instantly share code, notes, and snippets.

@Tonkpils
Created October 17, 2013 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tonkpils/7030746 to your computer and use it in GitHub Desktop.
Save Tonkpils/7030746 to your computer and use it in GitHub Desktop.
Finding this issue made me LOL
fun get_nth (words : string list, n : int) =
if n = 1
then (hd words)
else get_nth((tl words), n - 1)
fun date_to_string(date : int*int*int) =
let
val months = ["January", "February", "March", "April", "June",
"July", "August", "September", "October", "November", "December"]
val month = get_nth(months, #2 date)
in
month ^ " " ^ Int.toString(#3 date) ^ ", " ^ Int.toString(#1 date)
end
(* Find the error...*)
(* - date_to_string((2013, 6, 1)) = "June 1, 2013" *)
(* val it = false : bool *)
(* - date_to_string((2013, 6, 1)); *)
(* val it = "July 1, 2013" : string *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment