number_in_month exercise

前端 未结 4 1993
悲哀的现实
悲哀的现实 2021-01-17 04:17

I am fresh on SML and doing a homework by that. \"Write a function number_in_month that takes a list of dates and a month (i.e., an int) and returns how many dates in the li

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-17 04:34

    I tried to fix it by myself and that was my solution:

    fun number_in_month (dias: (int*int*int) list,mes:int) = if null dias then 0 else if ((#2 (hd dias)) = mes) then let val flag = 1 + number_in_month(tl dias, mes) in flag end else number_in_month((tl dias),mes)

    I hope you can also use it!

提交回复
热议问题