Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Samenvatting hoofdstuk 3: Uitgestelde (Lazy) Evaluatie

Rating
-
Sold
-
Pages
11
Uploaded on
27-07-2022
Written in
2019/2020

Dit is de samenvatting van het derde hoofdstuk van het vak Interpretatie van Computerprogramma's I. In deze samenvatting werd zowel alle informatie uit de slides als bijkomende informatie uit eigen notities opgenomen. Aan het einde van de samenvatting werden ook de herhalingsvragen opgelost EINDRESULTAAT: 16/20

Show more Read less
Institution
Course

Content preview

Hoofdstuk 3: Uitgestelde (lazy) evaluatie
1 Context: normal vs. applicative order
1.1 Applicative order voor evaluatie van operands
• eval evalueert voor een procedure-oproep de operator en alle operands anticipatief
• apply ontvangt de resulterende procedure en lijst van waarden




1.2 Normal order voor evaluatie van operands
• eval evalueert voor een procedure-oproep alleen de operator maar nog niet de operands
• apply ontvangt de resulterende procedure en een lijst van expressies
o de evaluatie van elk van deze expressies wordt uitgesteld
▪ tot haar waarde geprint moet worden op de read-eval-print loop
▪ tot haar waarde nodig is om te beslissen over de control flow (e.g.,
predicaat-deelexpressie van een if-expressie)
▪ tot haar waarde als concreet argument
moet dienen voor een primitieve die
“strikt” is in de corresponderende
parameter
• Voorbeeld: “+” is strikt in elk van zijn parameters maar cons-stream
niet in 2e parameter

2 Voorstelling van uitgestelde waarden: thunks




1

, (define (delay-it exp env)
(list 'thunk exp env))
Env wordt bijgehouden omdat, wanneer expressie uiteindelijk wel
geëvalueerd kan worden, we een env nodig hebben.

(define (thunk? obj)
(tagged-list? obj 'thunk))

(define (thunk-exp thunk)
(cadr thunk))

(define (thunk-env thunk)
(caddr thunk))

3 Uitgestelde waarden berekenen




(define (force-it obj)
Obj is een thunk of een waarde
(if (thunk? obj)
Als het nog een thunk is, actual-value berekenen
(actual-value (thunk-exp obj) (thunk-env obj))
Anders gewoon waarde teruggeven → recursie stopt
obj))

(define (actual-value exp env)
(force-it (eval exp env)))
Uit eval komt een waarde of een thunk → forceren

4 Aanpassing van de read-eval-print loop
(define input-prompt ";;; L-Eval input:")
(define output-prompt ";;; L-Eval value:")


2

Connected book

Written for

Institution
Study
Course

Document information

Summarized whole book?
No
Which chapters are summarized?
Hoofdstuk 4.2
Uploaded on
July 27, 2022
Number of pages
11
Written in
2019/2020
Type
SUMMARY

Subjects

$4.68
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF


Also available in package deal

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
lennyS Vrije Universiteit Brussel
Follow You need to be logged in order to follow users or courses
Sold
166
Member since
6 year
Number of followers
62
Documents
34
Last sold
1 month ago

4.5

6 reviews

5
4
4
1
3
1
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions