Lazy Evaluation Flashcards

1
Q

describe Haskell evaluation

A

> avoids unnecessary evaluation
allows programs to be modular
allows programming with infinite lists

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

what is Haskell the only fp language to use?

A

Lazy Evaluation

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

how are expressions evaluated?

A

by successively expanding definitions by evaluation / reducing redexes until no further simplification is possible.

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

how do you reduce a 𝛿-redex?

A

by expanding a definition

e.g. square(7) -> 7*7

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

how do you reduce a β-redex?

A

(\x.b[x])(a) -> b[x]

e.g. if + = \xy. … then reducing 3 + 4 involves β-reduction

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

Church-Rosser theorem

A

if e evaluates to e1 and e2, then there exists an expression e’ such that e1 and e2 both evaluate to e’

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

Church-Rosser properties

A

the final result of evaluating an expression is independent on the evaluation order.

In Haskell, 2 different ways of evaluating the same expression will always give the same final result

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

What is Innermost reduction?

A

always selecting the innermost redex to reduce. (call by value)

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

What is Outermost reduction?

A

always selecting the outermost redex to reduce. (call by name)

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

what are the advantages of Outermost reduction over Innermost reduction?

A

outermost may give a result where innermost fails to terminate.

for any expression, if there exists and reduction sequence that terminates, then the outermost reduction will also terminate with the same result.

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

what are the disadvantages of outermost reduction? what is the solution?

A

it may require more steps.

solved using sharing.

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

what is sharing?

A

using pointers to indicate sharing of expressions during evaluation

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

What is Lazy Evaluation made up of?

A

outermost reduction + sharing

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