不太像 (swi) prolog 的寻呼机

发布于 2024-10-04 03:29:21 字数 569 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩饰不了的爱 2024-10-11 03:29:21

这不是一个完整的解决方案,但是编写您自己的 pager 谓词不是很容易吗?步骤:

  1. 创建临时文件

  2. 借助 这些那些谓词

    (我还没有使用 Prolog 进行任何 I/O,但看起来并不太混乱)

  3. less进行系统调用

This is not a complete solution, but wouldn't it be rather easy to write your own pager predicate? Steps:

  1. Create temp file

  2. 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)

  3. make a system call to less <tempfile>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文