[英]beta reduction strategies in Haskell
This is my first time learning functional programming.这是我第一次学习函数式编程。 I do understand how simple beta reduction works.
我确实理解简单的 beta 减少是如何工作的。
for example:例如:
(\x->2*x)5
means that you substitute the xs with 5.意味着您将 xs 替换为 5。
2*5=10
However, other examples confuse me然而,其他例子让我感到困惑
(\f->f(f 0))(\x->x+1)
We have learned about some evaluation strategies, head normal form and weak head normal forms.我们已经了解了一些评估策略,头范式和弱头范式。
from my notes, I understand that head normal form means no redex expression, while weak head normal form means there is a lambda abstraction.从我的笔记中,我明白头部范式意味着没有 redex 表达式,而弱头部范式意味着存在 lambda 抽象。
This doesn't make any sense to me.这对我来说没有任何意义。 Do one of the two apply to this last example?
两者之一是否适用于最后一个示例? If so, what would be an example of the other strategy?
如果是这样,其他策略的例子是什么?
The term期限
(\f -> f (f 0)) (\x -> x+1)
is neither in head normal form nor in weak head normal form.既不是头部范式也不是弱头部范式。 This term is the application of a lambda (specifically,
\\f -> f (f 0)
) to a term (specifically, \\x -> x+1
), and so:这个术语是一个 lambda(特别是
\\f -> f (f 0)
)到一个术语(特别是\\x -> x+1
)的应用,所以:
Neither "head normal form" nor "weak head normal form" is an evaluation strategy. “头范式”和“弱头范式”都不是评估策略。 Forms are adjectives which describe terms;
形式是描述术语的形容词; evaluation strategies, in general, are verbs which describe how to change one term into another term.
评估策略通常是描述如何将一个术语变为另一个术语的动词。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.