I am doing a programming assignment with SML. One of the functions requires me to return a list of triple tuples of ints ( (int * int * int) list ) use to other lists. The function sorts through dates and months to see if any of them coincide, if they do, then they add it to the list. Here is the code for that.
fun dates_in_month (dates : (int * int * int) list, month : int) =
if null dates
then []
else
if #2 (hd dates) = month
then (hd dates) :: dates_in_month(tl dates, month)
else dates_in_month(tl dates, month)
fun dates_in_months (dates : (int * int * int) list, months : int list) =
if null months orelse null dates
then []
else
dates_in_month(dates, hd months) ::
dates_in_months(dates, tl months)
Using this code works to a point, however the function returns an (int * int * int) list list, instead of a (int * int * int) list. I think the problem lies with the
then []
statement. Any help would be appreciated.