Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.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
Debugging Prolog-使用maplist应用参数_Debugging_Prolog_Maplist - Fatal编程技术网

Debugging Prolog-使用maplist应用参数

Debugging Prolog-使用maplist应用参数,debugging,prolog,maplist,Debugging,Prolog,Maplist,我想了解我的错误是什么,这段代码用于带有列表的maplist的自定义谓词: generateProjection(TableOrTables/Selectors, Row, Result) :- writeln(kiki), writeln(TableOrTables), writeln(Selectors), writeln(Row), Result = 1/2. compute_projection(Rows, TableOrTables, Sel

我想了解我的错误是什么,这段代码用于带有列表的maplist的自定义谓词:

generateProjection(TableOrTables/Selectors, Row, Result) :- 
    writeln(kiki),
    writeln(TableOrTables),
    writeln(Selectors),
    writeln(Row),
    Result = 1/2.

compute_projection(Rows, TableOrTables, Selectors, Result) :- 
    writeln(hello),
    writeln(Rows),
    writeln(Selectors),
    maplist(
        generateProjection(TableOrTables/Selectors),
        Rows,
        Result
    ).
此查询可用于:

generateProjection(foo/[foo/bar, foo/baz], [1, 2], Z).
鉴于这一点失败:

compute_projection([[1, 2], [3, 4]], foo, [foo/bar, foo/baz], _4552/_4554).

感谢您的帮助

让我们看看您的第二个问题:

?- compute_projection([[1,2],[3,4]], foo, [foo/bar,foo/baz], _A/_B). 因此,
Result
是一个列表,但查询需要一个形式为
\uu/
的术语


这就是查询无法成功的原因。

我想在compute_projection中做的是生成一个由generateProjection生成的u/u列表(这样我就可以在上面使用findall)。我怎样才能修好它?使用另一个变量?@jy95。你已经在这么做了。因此,
Result
的形式为
[]
[\u/\ u]
[\u/\ uu、\u/\ u]
等。。。用变量替换
\u A/\u B
后再次运行查询…感谢您的回答:) compute_projection(Rows, TableOrTables, Selectors, Result) :- maplist(generateProjection(TableOrTables/Selectors), Rows, Result).