Last active
December 25, 2015 09:39
-
-
Save zendeavor/6956149 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
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 |
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
(* | |
* 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