Haskell与Prolog的比较 [英] Haskell vs. Prolog comparison
问题描述
编辑
是否有一个可以模仿Prolog功能的Haskell库(一种逻辑解算器)?
< Prolog主要是针对逻辑问题的语言,特别是来自AI和语言领域的语言。 Haskell更多的是一种通用语言。
Prolog是声明性(逻辑)语言,它使得更容易说明逻辑问题。 Haskell是一种功能语言,因此更适合计算问题。
维基百科声明式编程:
在计算机科学中,声明式
编程是一种编程范式
,它表示
计算的逻辑,而不描述它的
控制流。它试图最小化
或消除
的副作用,描述
完成的程序,而不是描述
如何完成它。这是
与命令性的
编程形成鲜明对比,这需要详细的
描述算法为
run。
声明式编程认为
程序是正式的
逻辑的理论,并且在该逻辑空间中计算为扣除
。声明式
编程最近已成为特别
利息,因为它可能大大简化编写并行程序
。
关于函数式编程的维基百科:
在计算机科学中,函数
编程是一种编程范例
,计算作为数学函数
的
评估并避免状态和可变数据。它
强调
函数的应用,与
命令式编程风格相反,
强调状态的变化。
lambda演算函数式编程的根源
,20世纪30年代开发的正式
系统调查函数定义,
函数应用程序和递归。
许多函数式编程语言
可以看作是
lambda微积分的修饰。
In简言之,声明性语言声明了一组关于哪些输出应该从哪些输入中产生并使用这些规则来推断输入的输出的规则集,而功能性语言声明了一组定义如何将输入转换为输出的数学或逻辑函数。
至于ADDED问题:我没有知道但你可以翻译 Haskell to Prolog,或 / prolog-in-haskell.htmlrel =noreferrer> implement What kind of problems is better solved in Prolog than in Haskell? What are the main differences between these two languages? Edit Is there a Haskell library (kind of a logical solver) that can mimic Prolog functionality? 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 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: 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. 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屋!