2014-03-29 113 views
0

好了,對不起你們,其我再次X) 這個功能應該更換的子樹DT(其在由座標指定的座標是二叉樹)(如[ 0; 1; 0; 0],其中0表示向左,1表示相反)由子樹nt。 順便說一下,子函數返回具有指定座標的子樹。 我得到一個語法錯誤OCaml的奇怪的語法錯誤

else if (List.hd coord)=0 then edit l coord nt 
Error: Syntax error 
# 

我真的不知道爲什麼:S 不管怎樣,謝謝:)

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

回答

0

我說,你只需要在那裏擺脫多餘的let

+0

感謝的人,我也有選擇和成本在「機會」選項卡,而不是概率和事件x)我真的需要一個睡眠 – MMrj