Lazy evaluation Flashcards

1
Q

How are expressions in Haskell evaluated?

A

Lazy evaluation

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

What are the benefits of lazy evaluation?

A
  • Avoids doing unnecessary evaluation
  • Ensures termination whenever possible
  • Supports programming with infinite lists
  • Allows programs to be more modular (separates control and data)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If the program terminates, what can we say about the ways of evaluating the same expression?

A

Anyway of evaluating the same expression will give the same result provided it terminates

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

What is a redex?

A

A reducible expression

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

What are the two main evaluation strategies?

A
  • Choose a redex that is innermost (doesn’t contain another redex)
  • Choose a redex that is outermost (is not contained in another redex)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Compare termination with innermost and outermost evaluation

A

Outermost evaluation may give a result when innermost evaluation fails to terminate

If any evaluation sequence terminates, then so does the outermost, with the same result

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

Compare the number of reduction steps with innermost and outermost evaluation

A

Outermost evaluation may require more steps than innermost

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

How do we reduce the number of steps in outermost evaluation?

A

Using pointers to indicate sharing of arguments

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

What is lazy evaluation?

A

Lazy evaluation = outermost evaluation + sharing of arguments

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

What does Lazy Evaluation ensure?

A

Termination whenever possible, it never requires more steps then innermost evaluation

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

What is modular programming?

A

Seperating control from data
LE allows this

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