this is homework from the ProgLang course at Coursera but the due date has passed and I'm only auditing this. This is a really cheap problem but it looks like I can't do this in SML.
Given a list of date 3-tuples of int and an int, return how often that int matches #2 of the tuple (the month).
At first I had a lot of [tycon mismatch] and then played around with the function header. I have no idea how to denote a list of tuples, prolly all down to that.
fun number_in_month (date : [int*int*int], month : int) : int =
if hd date = []
then 0
else
if #2 hd date = month
then
1 + number_in_month tl date
else
0 + number_in_month tl date
Not sure about the logic and the if then else if construct either. And what on earth is AS ?
- use "hw1.sml";
[opening hw1.sml]
hw1.sml:13.26 Error: syntax error: replacing COLON with AS
val it = () : unit
13:26 is the first colon of the header. Maybe I'm too numb to google too, I did not find anything useful.