Search code examples
syntax-errorsml

SML - Errors in code


I'm making an SML lambda calculus translation function and I have run into several errors and I don't know how to fix it.

    cfunf id (CAPP(e1,e2))=
          if not(cfree id (CAPP(e1,e2)))
             then CAPP(CK,CAPP(e1,e2))
             else
             if ((CID id) = e2) andalso not(cfree id e1)
             then e1
             else CAPP(CAPP(CS, (cfunf id e1)),(cfunf id e2));

The errors I get are RPAREN THEN and ELSE IDA. I'm pretty sure RPAREN is for an unbalance in parenthesis but there is none I can see. This code is required for the following function. I'm sure it some simple syntax error but I have no idea how too proceed so any help will be appreciated.


Solution

  • You added and extra parenthesis. Remove the last ) from

    if ((CID id) = e2) andalso not(cfree id e1))
    

    So it becomes

    if ((CID id) = e2) andalso not(cfree id e1)