实施"对于循环"在序言序言、QUOT

2023-09-11 22:45:55 作者:凉城

如何实现使用递归和切断反周期 (如对于i:= 1 DOWNTOñ做<运营商> )?

How to Implement using recursion and cut-off cycle of the counter (like for i: = 1 downto N do <operator>) ?

推荐答案

简短的回答是,你不知道。

The short answer is that you don't.

Prolog是一个declaritive语言,而不是一种程序语言。它来自于predicate结石。你描述的事实和规则(下称数据库)方面的问题空间。这形成了联系,向图的集合。

Prolog is a declaritive language, not a procedural language. It comes from the predicate calculus. You describe the problem space in terms of facts and rules (the "database"). This forms a collection of connected, directed graphs.

您制定一个描述解决您的问题的最初目标,让推理引擎找到解决方案(S),如果有的话。

You formulate an initial goal that describes the solution to your "problem" and let the inference engine find the solution(s), if any.

推理引擎开始,你给它最初的目标。它计算它在数据库方面,走在曲线图,因为它的推移,回溯失败,直到它找到一个解决方案(或没有)。回溯到初始目标将导致它来寻找下一个解决方案,如果有的话。

The inference engine starts with the initial goal you give it. It evaluates it in terms of the database, walking the graph as it goes, backtracking on failure, until it finds a solution (or not). Backtracking into the initial goal will cause it to look for the next solution, if any.

因此​​,一个程序结构的概念,比如一个循环是相当不地道(至少可以这样说),并(在我的经验,至少)是pretty的许多表现不佳的保证。

So the notion of a procedural construct such as a loop is rather non-idiomatic (to say the least) and (in my experience, at least) is pretty much a guarantee of poor performance.

 
精彩推荐
图片推荐