15. Lazy evaluation Flashcards
What is a reducible expression (redex)
An expression that has the form of a function applied to one ore more arguments that can be reduced.
Describe innermost evaluation
Always choose a redex that is innermost before it is passed into a function.
Describe ‘passed by value’
The arguments are fully evaluated before being passed into a function.
Describe outermost evaluation
Always evaluate an expression before evaluating it’s arguments.
Describe ‘passed by name’
The function is applied before the arguments have been evaluated
which one is prefered: call-by-value or call-by-name and why?
Call-by-name is preferable, it ensures that evaluation terminates as often as possible. Allows us to work with infinite structures.
How do you use strict applications? Give an example
Using $!, forces an evaluation.
example: f $! x this forces x to be evaluated before being parsed into f.