Skip to content

Instantly share code, notes, and snippets.

@zendeavor
Last active December 25, 2015 09:39
Show Gist options
  • Save zendeavor/6956149 to your computer and use it in GitHub Desktop.
Save zendeavor/6956149 to your computer and use it in GitHub Desktop.
Standard ML of New Jersey v110.76 [built: Fri Oct 11 16:38:25 2013]
- use "hw1.sml";
[opening hw1.sml]
hw1.sml:29.18-30.33 Error: operator and operand don't agree [type mismatch]
operator domain: {2:'Y; 'Z}
operand: date list
in expression:
(fn {2=2,...} => 2) d
uncaught exception Error
raised at: ../compiler/TopLevel/interact/evalloop.sml:66.19-66.27
../compiler/TopLevel/interact/evalloop.sml:44.55
../compiler/TopLevel/interact/evalloop.sml:296.17-296.20
(*
* date is int * int * int
* where:
* first field is a four-digit year
* second field is two-digit month [1,12]
* third field is two-digit day [1,31]
*)
type date = int * int * int
fun number_in_month (dates : date list, month : int) : int =
let
fun loop (acc : int, d : date list) : int =
if null d then acc
else if #2 d = month then loop(acc+1, tl d)
else loop(acc, tl d)
in
loop(0, dates)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment