我想知道一个 Prolog 可能包含这样的内置调用:
accum(generator, filter, accumulator)
Calculates all solutions to generator.
For each one, if filter can be proved, accumulator is proved.
Backtracks to find all solutions to filter and generator.
Accumulator may backtrack internally, but multiple proofs of accumulator are
conjoined, not backtracked.
因此,例如,要在不使用递归的情况下对列表求和,您可以编写:
X is 0, accum(member(Val,List), True, X is X + Val).
是否有任何带有此构造的 Prolog 或等价物?请记住,我是 Prolog 的新手,可能会遗漏一些明显的东西。