I'd say you just need to get rid of the extra let
in there.
OCaml Strange Syntax Error
-
23-06-2023 - |
Question
Okay, sorry guys, its me again x) This function is supposed to replace a sub-tree of dt (which is a binary tree) at the coordinates specified by coord (like [0;1;0;0] where 0 means going left and 1 the opposite) by the sub tree nt. By the way, the sub function returns the subtree with the specified coordinates. I'm getting a syntax error
else if (List.hd coord)=0 then edit l coord nt
Error: Syntax error
#
i really dont know why :S Thanks anyway :)
let rec edit dt coord nt =
match dt with
Decision(choiceL, costL, l, choiceR, costR, r) -> if (sub dt coord)=l then Decision(choiceL, costL, nt, choiceR, costR, r)
else if (sub dt coord)=r then Decision(choiceL, costL, l, choiceR, costR, nt)
else if (List.hd coord)=0 then edit l coord nt
else edit r coord nt
| Chance(eventL, probL, l, eventR, probR, r) -> if (sub dt coord)=l then Chance(choiceL, costL, nt, choiceR, costR, r)
else if (sub dt coord)=r then let Chance(choiceL, costL, l, choiceR, costR, nt)
else if (List.hd coord)=0 then edit l coord nt
else edit r coord nt
| Outcome value -> raise (Arg.Bad ("Bad argument"))
;;
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow