I’m learning OCaml for the first time, and I am having a bit of trouble with an extraordinarily vague “Syntax error”.
When defining the function generateboxes like so:
let rec generateboxes a b =
if a = (add1 b) then (force_newline ()); (print_sting "Done!")
else if [1] = (Array.get finalarray a) then (populatebox
(numbertoposition a) a); (generateboxes (add1 a) b)
else (generateboxes (add1 a) b);;
The complier gives the error message: “Syntax error” and it points to the first else. Is there anything glaringly wrong with my code for it to output such a message? (I realize the code is out of context, but if its a syntax error then it shouldn’t matter).
If you have more than one statement in a
thenor anelseclause, you need to put them inside parentheses.Alternatively, you can put
begin ... endaround them:(Note that I have also removed a few unnecessary parentheses to make the code clearer.)