简体   繁体   中英

OCaml Strange Syntax Error

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")) 
    ;;

我要说的是,您只需要摆脱那里的多余let

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM