[SOLVED] CS320 Exercise #1-Free Identifiers

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon ex01-dwjdwc.zip (50.4 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

1         Free Identifiers

Implement the function freeIds, which takes a WAE and produces a set of strings. The set should contain a string for each free identifier in the given WAE.

def freeIds(expr: WAE): Set[String] = ???

test(freeIds(WAE(“{with {x 1} {+ x y}}”)), Set(“y”)) test(freeIds(WAE(“{with {z 2} 1}”)), Set())

2          Binding Identifiers

Implement the function bindingIds, which is like freeIds, but the result set contains a string for each binding identifier in the given WAE (whether or not the binding identifier is ever referenced by a bound identifier).

def bindingIds(expr: WAE): Set[String] = ???

test(bindingIds(WAE(“{with {x 1} {+ x y}}”)), Set(“x”)) test(bindingIds(WAE(“{with {z 2} 1}”)), Set(“z”))

3         Bound Identifiers

Implement the function boundIds, which is like freeIds, but the result set contains a string for each bound identifier in the given WAE.

def boundIds(expr: WAE): Set[String] = ???

test(boundIds(WAE(“{with {x 1} {+ x y}}”)), Set(“x”)) test(boundIds(WAE(“{with {z 2} 1}”)), Set())

  • ex01-dwjdwc.zip