Eager evaluation/applicative order and lazy evaluation/normal order

后端 未结 3 1421
[愿得一人]
[愿得一人] 2021-02-05 11:05

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 argu

3条回答
  •  孤独总比滥情好
    2021-02-05 11:43

    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.

    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).

提交回复
热议问题