I have previous asked, but no answer so I will try to rewrite the problem.
I have two lists. first list is dates (int * int * int) list and second list is only months. eg(1,2,3,4,5,6,7,8,9,10,11,12
) int list
NOTE: assume any number in month list is not repeated and only 1-12.
I want to check how many dates has the same month as in the list of month.
example: [(87,09,08),(67,08,17),(90,08,23)], [1,5,8] = 2
I know how to recursively compare a list with a number, but i cant figure out how to recursivly compare a list with a list...
fun number_in_months (dates :( int * int * int) list, months : int list)=
if null dates
then 0
else if null months
then 0
else
let
fun dm_notempty (dates : (int * int * int) list, months : int list)=
if (null (tl dates) andalso null (tl months)) andalso (#2 (hd dates) <> hd months)
then 0
else if (null (tl dates) andalso null (tl months)) andalso (#2 (hd dates) = hd months)
then 1
else
let val dates_tl = dm_notempty(tl dates, tl months)
in
if #2(hd dates) = hd months
then dates_tl + 1
else dates_tl + 0
end
in
dm_notempty(dates, months)
end