number_in_month exercise (Don't understand why I'm getting “Syntax Error at EOF” in SML)

一曲冷凌霜 提交于 2021-01-29 04:45:11

问题


I'm supposed to write a program that takes a list of dates and then a month and returns the number of dates that include the month. I keep getting a syntax error and I don't understand why.

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

回答1:


It looks like you're missing the end statement for your outermost let, as well as an else clause to your second if statement.

Certainly, the first of these will cause a syntax error at EOF. I'm not sure about the second one, but I believe that it will as well.



来源:https://stackoverflow.com/questions/19388391/number-in-month-exercise-dont-understand-why-im-getting-syntax-error-at-eof

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!