Question: Please answer the following question in racket language. The template is provided below Template ;; define (define (define? node) 'todo) (define (define-basic? node) 'todo) (define
Please answer the following question in racket language. The template is provided below
Template
;; define (define (define? node) 'todo) (define (define-basic? node) 'todo) (define (define-func? node) 'todo)
4. (9 points) Your goal is to check if a datum is syntactically valid, uith respect to the specification we intro- duced in Lecture 1 and Lecture 2. Recall function quote from Lecture 3. This function produces a logical representation of the code given as parameter. The serialized code that results from quote is known as a datum, or a quoted term. In the following exercises, the quoted term shall not include boolean expressions and conditionals. A quoted expression will include numbers, define, lambda, and function application. For the sake of simplicity, there is no need to recursively check the syntactic validity (eg, you do not need to check the if the body of a lambda is syntactically valid). For instance, given a lambda are the parameters symbols? Does the body of a lambda has expected number datums as we discussed in class? You do not need to check the semantic validity of the datum (eg, check if a variable is defined) (g) (0.2 points) Function define? takes a datum and returns a boolean whether or not the quoted term is a define. (check-true (define? (quote (define x 3)))) (h) (1 point) Function define-basic? takes a datum and returns a boolean whether or not the quoted term is a basic definition, according the specification in Lecture 2. (check-true (define-basic? (quote (define x 3)))) (i) (2.8 points) Function define-func? takes a datum and returns a boolean whether or not the quoted term is a function definition, according to the specification in Lecture 2. (check-true (define-func? (quote (define (x) 3)))) 4. (9 points) Your goal is to check if a datum is syntactically valid, uith respect to the specification we intro- duced in Lecture 1 and Lecture 2. Recall function quote from Lecture 3. This function produces a logical representation of the code given as parameter. The serialized code that results from quote is known as a datum, or a quoted term. In the following exercises, the quoted term shall not include boolean expressions and conditionals. A quoted expression will include numbers, define, lambda, and function application. For the sake of simplicity, there is no need to recursively check the syntactic validity (eg, you do not need to check the if the body of a lambda is syntactically valid). For instance, given a lambda are the parameters symbols? Does the body of a lambda has expected number datums as we discussed in class? You do not need to check the semantic validity of the datum (eg, check if a variable is defined) (g) (0.2 points) Function define? takes a datum and returns a boolean whether or not the quoted term is a define. (check-true (define? (quote (define x 3)))) (h) (1 point) Function define-basic? takes a datum and returns a boolean whether or not the quoted term is a basic definition, according the specification in Lecture 2. (check-true (define-basic? (quote (define x 3)))) (i) (2.8 points) Function define-func? takes a datum and returns a boolean whether or not the quoted term is a function definition, according to the specification in Lecture 2. (check-true (define-func? (quote (define (x) 3))))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
