El 09/07/15 a les 16:51, Gabriel Riba ha escrit:
Trying to use mutually recursive values don't compile, giving the error:

syntax error: replacing  AND with  UNDER
Parse failure
----------

Here is a sample to try with:

   val rec even (i:int) = if i = 0 then True
                        else if i > 0 then odd (i -1)
                        else error <xml>error: negative input</xml>

   and val rec odd (i:int) = if i = 0 then False
                           else if i > 0 then even (i -1)
                           else error <xml>error: negative input</xml>


I am sorry, I see it was my fault, as the syntax is defined in the manual as

val rec (id : type = expr "and")+


I should have written:

    val rec even (i:int) = if i = 0 then True
                         else if i > 0 then odd (i -1)
                         else error <xml>error: negative input</xml>

    and odd (i:int) = if i = 0 then False
                            else if i > 0 then even (i -1)
                            else error <xml>error: negative input</xml>



_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur

Reply via email to