15. Lazy evaluation Flashcards

1
Q

What is a reducible expression (redex)

A

An expression that has the form of a function applied to one ore more arguments that can be reduced.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe innermost evaluation

A

Always choose a redex that is innermost before it is passed into a function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe ‘passed by value’

A

The arguments are fully evaluated before being passed into a function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe outermost evaluation

A

Always evaluate an expression before evaluating it’s arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe ‘passed by name’

A

The function is applied before the arguments have been evaluated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

which one is prefered: call-by-value or call-by-name and why?

A

Call-by-name is preferable, it ensures that evaluation terminates as often as possible. Allows us to work with infinite structures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you use strict applications? Give an example

A

Using $!, forces an evaluation.
example: f $! x this forces x to be evaluated before being parsed into f.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly