Ml function probem

Trying to do a simple function in ml but I'm getting an uncaught exception error and I have no clue what's wrong with it.
fun number_in_month (dl : (int*int*int) list, m : int) =
    if #2 (hd dl) = m andalso null (tl dl)
    then 1
    else if #2 (hd dl) = m
    then 1 + number_in_month(tl dl, m)
    else 0 + number_in_month(tl dl, m)

Comments

  • Ok, that's taken care of. But now I've got an unbound variable problem with this:
    fun number_in_month (dl : (int*int*int) list, m : int) =
        if #2 (hd dl) = m andalso null (tl dl)
        then 1
        else if #2 (hd dl) <> m andalso null (td dl)
        then 0
        else if #2 (hd dl) = m
        then 1 + number_in_month(tl dl, m)
        else 0 + number_in_month(tl dl, m)
    
  • never heard of that language.
  • It's also called SML (standard ML). It's a functional language. I just started playing around with it a week ago. I guess it's obscurity does make the topic title a little.... confusing..?
Sign In or Register to comment.