不太像 (swi) prolog 的寻呼机
Unix 中的典型工作流程是使用一系列过滤器,最后是一个寻呼机,例如 less。例如(省略参数)
grep | sed | awk | less
现在,swi-prolog 命令行中的典型工作流程之一是要求它为给定的连接提供一组解决方案,例如
foo(X),bar(X, Y),qux(buz, Y).
它很容易为我提供一组解决方案。它可以比终端窗口长得多。或者单个查询
give_me_long_list(X).
可能会再次给出一个非常长的列表,不适合屏幕。因此,我经常发现自己处于想要在行尾敲击 |less
的情况。
我正在寻找的是一种在寻呼机中打开一组解决方案或只是一个大术语的工具。类似于:
give_me_long_list(X), pager(X).
或
pager([X,Y], (foo(X),bar(X, Y),qux(buz, Y))).
The typical workflow in unix is to use a pipeline of filters ending up with a pager such as less. E.g. (omitting arguments)
grep | sed | awk | less
Now, one of the typical workflows in the swi-prolog's command line is asking it to give the set of solutions for a given conjunction like
foo(X),bar(X, Y),qux(buz, Y).
It readily gives me the set of soutions. Which can be much longer than the terminal window. Or a single query
give_me_long_list(X).
can give a very long list again not fitting on the screen. So I constantly find myself in situations where I want to slap |less
at the end of the line.
What I am looking for is a facility to open in a pager a set of solutions or just a single large term. Something similar to:
give_me_long_list(X), pager(X).
or
pager([X,Y], (foo(X),bar(X, Y),qux(buz, Y))).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是一个完整的解决方案,但是编写您自己的
pager
谓词不是很容易吗?步骤:创建临时文件
借助 这些 或 那些谓词
(我还没有使用 Prolog 进行任何 I/O,但看起来并不太混乱)
对
less进行系统调用
This is not a complete solution, but wouldn't it be rather easy to write your own
pager
predicate? Steps:Create temp file
dump
X
into temp file with the help of these or those predicates(I haven't done any I/O with Prolog yet, but it doesn't seem too messy)
make a system call to
less <tempfile>