Haskell 与 Prolog 比较 [英] Haskell vs. Prolog comparison

查看:28
本文介绍了Haskell 与 Prolog 比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Prolog 比 Haskell 更能解决哪些问题?这两种语言的主要区别是什么?

What kind of problems is better solved in Prolog than in Haskell? What are the main differences between these two languages?

编辑

是否有可以模仿 Prolog 功能的 Haskell 库(一种逻辑求解器)?

Is there a Haskell library (kind of a logical solver) that can mimic Prolog functionality?

推荐答案

Prolog 主要是针对逻辑问题的语言,尤其是在 AI 和语言领域.Haskell 更像是一种通用语言.

Prolog is mainly a language targeted at logical problems, especially from the AI and linguistic fields. Haskell is more of a general-purpose language.

Prolog 是声明性(逻辑)语言,这使得在其中陈述逻辑问题变得更容易.Haskell 是一种函数式语言,因此更适合解决计算问题.

Prolog is declarative (logical) language, what makes it easier to state logical problems in it. Haskell is a functional language and hence much better suited to computational problems.

关于声明式编程的维基百科:

Wikipedia on declarative programming:

在计算机科学中,声明式编程是一种编程范式表达了一个逻辑计算而不描述其控制流.它试图最小化或消除副作用描述程序应该做什么完成,而不是描述如何去完成它.这是与命令式相反编程,这需要一个详细的算法描述运行.

In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow. It attempts to minimize or eliminate side effects by describing what the program should accomplish, rather than describing how to go about accomplishing it. This is in contrast from imperative programming, which requires a detailed description of the algorithm to be run.

声明式编程考虑作为形式理论的程序逻辑和计算作为推论在那个逻辑空间里.声明式编程变得特别最近的兴趣,因为它可能会大大简化编写并行程序.

Declarative programming consider programs as theories of a formal logic, and computations as deductions in that logic space. Declarative programming has become of particular interest recently, as it may greatly simplify writing parallel programs.

函数式编程的维基百科:

Wikipedia on functional programming:

在计算机科学中,函数式编程是一种编程范式将计算视为数学函数的评估并避免状态和可变数据.它强调应用功能,与命令式编程风格,其中强调状态的变化.函数式编程有其根源在 lambda 演算中,一个正式的1930 年代开发的系统调查函数定义,函数应用和递归.许多函数式编程语言可以看作是点缀λ演算.

In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state. Functional programming has its roots in the lambda calculus, a formal system developed in the 1930s to investigate function definition, function application, and recursion. Many functional programming languages can be viewed as embellishments to the lambda calculus.

简而言之,声明性语言声明了一组关于哪些输入应该产生哪些输出的规则,并使用这些规则从输入中推断出输出,而函数式语言声明了一组数学或逻辑函数,这些函数定义了输入的方式翻译成输出.

In short a declarative language declares a set of rules about what outputs should result from which inputs and uses those rules to deduce an output from an input, while a functional language declares a set of mathematical or logical functions which define how input is translated to output.

至于添加的问题:我不知道,但您可以 翻译 Haskell 到 Prolog,或 实现 Haskell 中的 Prolog :)

As for the ADDED question : none that I know of but you can either translate Haskell to Prolog, or implement Prolog in Haskell :)

这篇关于Haskell 与 Prolog 比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆