【问题标题】:OCaml Strange Syntax ErrorOCaml 奇怪的语法错误
【发布时间】: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


    【解决方案1】:

    我想说你只需要摆脱那里多余的let

    【讨论】:

    • 谢谢,我在“机会”选项卡中也有选择和成本,而不是概率和事件 x)我真的需要睡觉
    猜你喜欢
    • 1970-01-01
    • 2020-10-11
    • 1970-01-01
    • 2014-04-14
    • 2013-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多