快速在 Prolog 中运行

发布于 2024-08-16 08:58:54 字数 409 浏览 8 评论 0原文

我的公司有一个在 Prolog 中运行的项目,我想澄清一些有关如何学习它的事情。我知道 Prolog 是不同的。它不应该像任何其他语言一样学习。

话虽如此,考虑到我还没有接触过任何 Prolog 书籍,是否有任何书籍或在线资源可以让我像学习 C/C++ 一样学习 Prolog?我的意思是,要在 C/C++ 中运行,您只需要知道程序的结构,例如 main { }loopsconditions分支和一些可用于开始用 C/C++ 编写基本程序的函数

这样我就可以学习 Prolog,有没有什么书能让我了解如何用 Prolog 编程? (基础知识、循环、如何实现条件、程序结构、什么是谓词?如何使用它?如何定义它?等等...)。

My company has a project running in Prolog and I want to clarify few things about how to go about learning it. I know Prolog is different. It should not be learnt just like any other language.

Having said that, and considering the fact that I did not lay my hands on any Prolog book yet, Is there any book or online resource, where I can learn Prolog the way how we learn C/C++? What I mean is , just to be operational in C/C++, you just need to know the structure of the program, like main { } , loops, conditions, branches, and few functions that you can use to start writing basic programs in C/C++.

Just this way can I learn Prolog and is there any book that just gives me an idea how to Program in Prolog? (basics, loops, how to implement conditions, program structure, what's predicate? how to use it? how to define it? and so on...).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

鲜血染红嫁衣 2024-08-23 08:58:54

如果您想要一本书,我强烈推荐"Prolog 的艺术"

从 C/C++ 等语言转向 Prolog 不仅仅是学习的问题一种编程语言。这是一种完全不同的编程思维方式

Prolog 是关于向计算机提出问题(如果您愿意,也可以称为“查询”)。计算几乎是计算机试图回答你的问题的副作用。 没有与循环或条件等价的有意义的东西,因为 Prolog 程序员不会用这些术语来思考。

一个好的 Prolog 程序看起来就像是对你试图解决的问题的分解描述分解为递归案例和子问题,而不是组织成函数或类的指令列表。

学习 Prolog 的最好方法就是抛开以前的所有编程经验。事实上,考虑 C 和 C++ 会使 Prolog 更难学习和使用。尝试采用初学者的思维,也许采取一种更像代数学家而不是程序员的方法。

If you're after a single book, I can highly recommend "The Art of Prolog":

Coming to Prolog from something like C/C++ isn't just a matter of learning a programming language. It's a wholly different way of thinking about programming.

Prolog is about asking the computer questions (or 'queries' if you like). Computation is almost a side-effect of the computer trying to answer your question. There is no meaningful equivalent to loops or conditionals because a prolog programmer wouldn't think in those terms.

A good Prolog program looks like a description of the problem that you're trying to solve decomposed into recursive cases and subproblems rather than lists of instructions organised into functions or classes.

The best way to learn Prolog is to set aside all your previous programming experience. Actually thinking about C and C++ will make Prolog harder to learn and use. Try to adopt a beginner's mind and maybe an approach more like an algebraist than a programmer.

旧城烟雨 2024-08-23 08:58:54

作为其他答案中提到的 Prolog 教程和教科书的补充,我建议快速浏览一下这个简短的文档:

命令式程序员的 Prolog

我认为这是您正在寻找的内容的一部分。它不会教您 Prolog,但它将有助于弥合理解 Prolog 的差距。它使用经验丰富的非 Prolog 程序员能够理解的术语描述了 Prolog 的基础知识。例如,它向您展示了 Prolog 中的控制结构,即顺序、选择和重复。不过,它确实假设您已经开始学习 Prolog。

如果您想根据已知的知识来了解新的知识,那么这是很好的选择。然而,有了这些知识/理解,您最终可能会用 Prolog 语法编写 C 代码。祝你好运!

As a supplement to the Prolog tutorials and textbooks mentioned in the other answers, I would suggest having a quick look at this short document:

Prolog for Imperative Programmers

I think it's part of what you're looking for. It won't teach you Prolog, but it will help bridge the gap to understanding Prolog. It describes the basics of Prolog using terminology that experienced non-Prolog programmers would understand. For example, it shows you control structures in Prolog, i.e. sequence, selection and repetition. It does assume that you've already started learning Prolog, though.

It's good if you want to understand something new in terms of something you already know. However, armed with this knowledge/understanding, there is a risk that you could end up writing C code in Prolog syntax. Good luck!

最丧也最甜 2024-08-23 08:58:54

立即学习 Prolog 有什么问题吗?每次问到此类问题时,它通常都是首选推荐?

它可能无法准确地提供您想要的术语——我相信它甚至没有提到“谓词”(使用“事实、规则和查询”来代替)或“循环”(它只是显示如何使用递归来代替)—— - 但是,一旦概念清晰,正确使用术语应该是简单、快速和容易的,而“立即学习 Prolog”似乎确实在使概念清晰方面做得很好。

What's wrong with Learn Prolog Now, which is usually the top recommendation each time this kind of question gets asked?

It may not give you exactly the terminology you want -- I believe it doesn't even mention "predicate" (uses "Facts, Rules, and Queries" instead) or "loops" (it just shows how to use recursion instead) -- but getting the terminology right once the concepts are clear should be simple, fast, and easy, and "Learn Prolog Now" does seem to do a good job about making the concepts clear.

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