【发布时间】:2014-05-09 09:09:51
【问题描述】:
好的,对不起各位,又是我 x) 这个函数应该在 coord 指定的坐标处替换 dt 的子树(二叉树)(如 [0;1;0;0]其中 0 表示向左,1 表示相反)由子树 nt。 顺便说一句,sub 函数返回具有指定坐标的子树。 我收到语法错误
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"))
;;
【问题讨论】:
标签: syntax syntax-error ocaml binary-tree ml