Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write in racket. 4. Write a structurally recursive function (unused-var? v exp) that takes as input a symbol and an expression in the the little

Write in racket.

image text in transcribed

4. Write a structurally recursive function (unused-var? v exp) that takes as input a symbol and an expression in the the little language from class: : := | (lambda () ) | ( ) unused-var? returns true if v is declared as a variable anywhere in exp and never used. Recall that only lambda expressions can declare a variable. For example: ; x is declared and not used > (unused-var? 'x '(lambda (x) y)) #t ; x is declared *and* used > (unused-var? 'x '(lambda (y) (lambda (x) x))) #f ; ... but y is declared and not used > (unused-var? 'y '(lambda (y) (lambda (x) x))) #t ; here, x is declared and used in the app's argument > (unused-var? 'x '(a (lambda (z) (lambda (y) (lambda (x) x))))) #f 4. Write a structurally recursive function (unused-var? v exp) that takes as input a symbol and an expression in the the little language from class: : := | (lambda () ) | ( ) unused-var? returns true if v is declared as a variable anywhere in exp and never used. Recall that only lambda expressions can declare a variable. For example: ; x is declared and not used > (unused-var? 'x '(lambda (x) y)) #t ; x is declared *and* used > (unused-var? 'x '(lambda (y) (lambda (x) x))) #f ; ... but y is declared and not used > (unused-var? 'y '(lambda (y) (lambda (x) x))) #t ; here, x is declared and used in the app's argument > (unused-var? 'x '(a (lambda (z) (lambda (y) (lambda (x) x))))) #f

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

Step: 3

blur-text-image

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

Explain methods of metal extraction with examples.

Answered: 1 week ago