Question: 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.

Write in racket. 4. Write a structurally recursive function (unused-var? v exp)

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!