Prolog中的懒惰列表? [英] Lazy lists in Prolog?
本文介绍了Prolog中的懒惰列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Prolog中是否可能有懒惰列表?类似于以下内容:
Is it possible to have lazy lists in Prolog? Something like the following:
ones([1 | Y]) :- ones(Y).
尽管这显然不符合本文的要求.
Although this obviously doesn't work as it's written.
推荐答案
Markus Triska placed here in public domain some code worth to study:
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Prolog stream/lazy list demonstration
Written 2005 by Markus Triska (triska@gmx.at)
Public domain code.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
文档标题(对于Prolog流, prost )可以使文档成为很难找到,但是很有意义. 从上面引用:
The title of the document (prost, for Prolog streams) maybe make the document a bit difficult to find, but make sense. Quoting from the above:
此处,流"是指顺序",延迟列表", 延迟列表"等,如计算机的结构和解释 程序,而不是Prolog输入/输出流.
Here, "stream" is used in the sense of "sequence", "delayed list", "lazy list" etc. as in Structure and Interpretation of Computer Programs, not in the sense of a Prolog input/output stream.
这篇关于Prolog中的懒惰列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文