我应该编写一个程序,它获取日期列表,然后获取月份并返回包含该月的日期数。 我不断收到语法错误,我不明白为什么。
fun number_in_month (dates : int list, month : int) =
let val tally = 0
in
let fun tally_counter(tally_dates : int list)=
if (tally_dates[1]) = month
then (
tally = tally + 1
tally_counter(tl tally_dates)
)
else if null (hd tally_dates)
then tally
in
tally_counter(dates)
end
看起来您缺少最外层let
的end
语句,以及第二个if
语句的else
子句。
当然,其中第一个会导致 EOF 出现语法错误。我不确定第二个,但我相信它也会。