急切评估/适用顺序和懒惰评估/正常顺序 [英] Eager evaluation/applicative order and lazy evaluation/normal order

查看:88
本文介绍了急切评估/适用顺序和懒惰评估/正常顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,急切的求值/应用顺序会在应用函数之前先评估函数的所有参数,而懒惰的求值/正常顺序仅在需要时才对参数进行求值。

As far as I know, eager evaluation/applicative order evaluates all arguments to a function before applying it, on the other hand, lazy evaluation/normal order evaluates the arguments only when needed.

那么,渴望评估应用顺序以及惰性评估正常订单

谢谢。

推荐答案

惰性评估最多只能评估一个术语,而正常顺序会尽可能多地评估一个术语。因此,例如,如果您有 f(x)= x + x 并将其称为 f(g(42))然后 g(42)在懒惰求值或应用顺序下调用一次,但在正常顺序下调用两次。

Lazy evaluation evaluates a term at most once, while normal order would evaluate it as often as it appears. So for example if you have f(x) = x+x and you call it as f(g(42)) then g(42) is called once under lazy evaluation or applicative order, but twice under normal order.

至少在使用计算机程序的结构和解释中的应用顺序定义时,热切的评估和应用顺序是同义词,这似乎与您的匹配。 ( Wikipedia 对应用顺序的定义有些不同,并作为急切评估的特殊情况)

Eager evaluation and applicative order are synonymous, at least when using the definition of applicative order found in Structure and Interpretation of Computer Programs, which seems to match yours. (Wikipedia defines applicative order a bit differently and has it as a special case of eager evaluation).

这篇关于急切评估/适用顺序和懒惰评估/正常顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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