number_in_month练习(不明白为什么我在 SML 中出现"EOF 语法错误")



我应该编写一个程序,它获取日期列表,然后获取月份并返回包含该月的日期数。 我不断收到语法错误,我不明白为什么。

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

看起来您缺少最外层letend语句,以及第二个if语句的else子句。

当然,其中第一个会导致 EOF 出现语法错误。我不确定第二个,但我相信它也会。

最新更新