Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following code: (scheme) 01|(define (outer z) 02| (define x 2) 03| (define (in1) 04| (define z (+ 20 x)) 05| (in2)) 06| (define

Given the following code: (scheme)

01|(define (outer z) 02| (define x 2) 03| (define (in1) 04| (define z (+ 20 x)) 05| (in2)) 06| (define (in2) 07| (set! z (* z 10)) 08| z) 09| in1) 10| 11|(define closure (outer 30)) 12|(closure) 

[/6 marks] Draw a contour diagram at the start of line 5 (after calling the closure function on line 12, before calling in2 on line 5).

[/1 mark] What is the output of this code? (Using lexical scoping)

[/3 marks] Would this code work using dynamic scope as taught in lecture? If yes, provide the output. If no, explain why not.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions