Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following syntax for a term in the unsugared untyped calculus, represented as an s-expression: E ::= ( V E) | (E E) |

Consider the following syntax for a term in the "unsugared" untyped calculus, represented as an s-expression: E ::= ( V E) | (E E) | V.where V is a variable.

For example, the term fx.f(tgg) would be de-sugared to f.x.f((tg)g) and then represented as the s-expression ( f ( x (f ((t g) g)))). Write a scheme function fv which takes an s-expression of this sort, and returns a list of the free variables. E.g,

(fv '( f ( x (f ((t g) g)))))  (t g) 

or (g t).

N.B = I have tried to problem and asked on Chegg so many times but everytime I output I keep getting:

car: contract violation, expected: pair? given: #

Would appreciate some help on modifications and whats wrong with the code and why it keeps getting car violations?

image text in transcribed

123456789101112131415161718192021222324252627(define(fvsexp)(cond[(variable?sexp)(listsexp)][(lambda?sexp)(fv(cdrsexp))][(application?sexp)(union(fv(carsexp))(fv(cdrsexp)))]))(define(unionset1set2)(cond[(empty?set1)set2][(member?(carset1)set2)(union(cdrset1)set2)][else(cons(carset1)(union(cdrset1)set2))]))(define(member?itemset)(cond[(empty?set)#f][(equal?item(carset))#t][else(member?item(cdrset))]))(define(variable?sexp)(symbol?sexp))(define(lambda?sexp)(and(pair?sexp)(eq?(carsexp))))(define(application?sexp)(pair?sexp))

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions