(* Write a function dates_in_month that takes a list of dates and a month (i.e., an int) and returns a list holding the dates from the argument list of dates that are in the month. The returned list should contain dates in the order they were originally given. *)
fun dates_in_months( datelist : (int*int*int) list, month : int) =
if null(tl (datelist))
then if #2(hd (datelist)) = month then #2(hd (datelist)) :: [] else []
else if #2(hd (datelist)) = month
then #2(hd (datelist)) :: number_in_month(tl datelist, month)
else number_in_month(tl datelist, month)
This is the error I get:
hw1.sml:55.22-55.78 Error: operator and operand do not agree [tycon mismatch]
operator domain: int * int list
operand: int * int
in expression:
(fn {2=<pat>,...} => 2) (hd datelist) ::
number_in_month (tl datelist,month)
val it = () : unit
Any help appreciated.