Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 常见分析错误:";在;在调用其他函数OCaml的函数中_List_Function_Multidimensional Array_Ocaml - Fatal编程技术网

List 常见分析错误:";在;在调用其他函数OCaml的函数中

List 常见分析错误:";在;在调用其他函数OCaml的函数中,list,function,multidimensional-array,ocaml,List,Function,Multidimensional Array,Ocaml,这个解析错误是在[binding](in[expr])之后出现的 是我在Ocaml用户中搜索到的常见错误,但在我看到的示例中,我没有找到错误的答案,然后我将解释我的问题: 我声明了这个函数: let rec unit_propag xs = let cuAux = teste xs let updatelist = funfilter (List.hd(List.hd cuAux)) (xs) let updatelist2 = filtraelem (negar

这个
解析错误是在[binding](in[expr])之后出现的
是我在
Ocaml
用户中搜索到的常见错误,但在我看到的示例中,我没有找到错误的答案,然后我将解释我的问题:

我声明了这个函数:

let rec unit_propag xs  =

    let cuAux = teste xs 
    let updatelist = funfilter (List.hd(List.hd cuAux)) (xs) 
    let updatelist2 = filtraelem (negar(List.hd(List.hd cuAux))) (updatelist)

if(not(List.mem [] xs) && (teste xs <> []))
then 
    unit_propag updatelist2
;;
它说:

File "exc.ml", line 251, characters 20-22:
Parse error: "in" expected after [binding] (in [expr])
Error while running external preprocessor
Command line: camlp4o 'exc.ml' > /tmp/ocamlpp5a7c3d
然后我尝试添加一个
以及最后一个函数的行中出现的“我的”错误,这种情况下是
unit\u propag updatelist2

我做错了什么?人们通常说这种错误发生在代码之前,但是当我注释这个函数时,程序编译得非常完美

我需要发布更多的代码?或者我需要更清楚地回答我的问题? 这可以在Ocaml中实现吗?或者我正在做一些我做不到的事情


谢谢

错误消息说您在
中缺少
,因此通过添加
来解决它似乎很奇怪:-)

无论如何,在函数
unit\u propag
中添加了
let
关键字之后,您在
中缺少了关键字

你应该这样写:

 let funfilter elem xs = List.filter (fun inner -> not (List.mem elem inner)) xs;;

let filtraele elem l = List.map( fun y -> List.filter (fun x -> x <> elem) y)l;;

let teste xs = List.filter(fun inner ->(is_single inner)inner)xs;;

let is_single xs = function
|[_]    -> true
|_  -> false
;;
let negar l =
match l with
V x -> N x
|N x    -> V x
|B  -> T
|T  -> B
;;  
let rec unit_propag xs  =
    let cuAux = teste xs in
    let updatelist = funfilter (List.hd(List.hd cuAux)) (xs) in
    let updatelist2 =
        filtraelem (negar(List.hd(List.hd cuAux))) (updatelist)
    in
    if (not (List.mem [] xs) && (teste xs <> [])) then 
       unit_propag updatelist2
让rec unit_propag xs=
让cuAux=teste xs进入
让updatelist=funfilter(List.hd(List.hd cuAux))(xs)在
让updatelist2=
filtraelem(negar(List.hd(List.hd-cuAux))(updatelist)
在里面
如果(不是(List.mem[]xs)和(teste-xs[]),则
单元程序更新列表2
基本问题在这里已经解释了很多次(正如您所注意到的)。基本上,关键字
let
有两种用法。在外部级别,它定义模块中的值。在另一个定义中,它定义了一个局部变量,在
中必须后跟
。这三个
let
s在
unit\u-propag
的定义中


另一个解释
let
用法的尝试是:。

错误消息说您在
中缺少
,因此通过添加
来解决它似乎很奇怪:-)

无论如何,在函数
unit\u propag
中添加了
let
关键字之后,您在
中缺少了关键字

你应该这样写:

 let funfilter elem xs = List.filter (fun inner -> not (List.mem elem inner)) xs;;

let filtraele elem l = List.map( fun y -> List.filter (fun x -> x <> elem) y)l;;

let teste xs = List.filter(fun inner ->(is_single inner)inner)xs;;

let is_single xs = function
|[_]    -> true
|_  -> false
;;
let negar l =
match l with
V x -> N x
|N x    -> V x
|B  -> T
|T  -> B
;;  
let rec unit_propag xs  =
    let cuAux = teste xs in
    let updatelist = funfilter (List.hd(List.hd cuAux)) (xs) in
    let updatelist2 =
        filtraelem (negar(List.hd(List.hd cuAux))) (updatelist)
    in
    if (not (List.mem [] xs) && (teste xs <> [])) then 
       unit_propag updatelist2
让rec unit_propag xs=
让cuAux=teste xs进入
让updatelist=funfilter(List.hd(List.hd cuAux))(xs)在
让updatelist2=
filtraelem(negar(List.hd(List.hd-cuAux))(updatelist)
在里面
如果(不是(List.mem[]xs)和(teste-xs[]),则
单元程序更新列表2
基本问题在这里已经解释了很多次(正如您所注意到的)。基本上,关键字
let
有两种用法。在外部级别,它定义模块中的值。在另一个定义中,它定义了一个局部变量,在
中必须后跟
。这三个
let
s在
unit\u-propag
的定义中


下面是解释
let
用法的另一个尝试:。

真不敢相信我没有测试它!谢谢,现在我更了解这种情况了。真不敢相信我没有测试过!感谢现在我更好地理解了这种情况。使用适当的自动缩进工具,如ocaml模式、tuareg模式或ocp缩进,可以轻松避免此类问题。如果自动缩进结果与您认为的不同,则可能是您在附近的某个地方犯了语法错误。我现在使用自动缩进程序thnx来提示使用适当的自动缩进工具,如ocaml模式、tuareg模式或ocp缩进,可以轻松避免此类问题。如果自动缩进结果与您认为的不同,则可能是您在附近的某个地方犯了语法错误。我现在使用自动缩进程序thnx作为提示