Question: 1 Functions with Multiple Arguments ( with Deferred Substitutions ) Start with the f 1 WAE interpreter for deferred substitution, and extend the implementation to
Functions with Multiple Arguments with Deferred Substitutions
Start with the fWAE interpreter for deferred substitution, and extend the implementation to support any number of arguments to a function including zero and any number of arguments including zero in a function application:As with homework you must change the f WAE datatype, and you must thus provide a parse function that produces values of your modified fWAE datatype. It must accept a quoted expression and produce an nWAE value. Similarly, you must provide a parsedefn function to parse definitions.
See homework for details on these functions.
You must also provide an interpexpr function with signature:
fnWAE listof FunDef Number
This function should be a very simple wrapper for your interp function, which our tests will call on the results of your parsers. If yours is more than a few lines one line is possible you may be overthinking it
Errors
Your interpreter and parser must obey the formats and precedence rules described in homework
Otherwise, assume that the input to your parser is a wellformed program.
Conditionals
Add if a conditional expression. It has three subexpressions: Errors
Your interpreter and parser must obey the formats and precedence rules described in homework Otherwise, assume that the input to your parser is a wellformed program.
Conditionals
Add if a conditional expression. It has three subexpressions:
fnWAEcdots
Evaluating an if expression evaluates the first subexpression; if it produces then the result of the entire expression is the result of the second subexpression. Otherwise, the result is the result of the third subexpression.
Examples:
test interpexpr parse if
test interpexpr parse if Negative predicate
Implement, in the fnWAE language without any extensions, ie you cannot add new kinds of expressions to the language or to your interpreter a predicate neg? that determines if an integer is negative. That is write a defun like this one that can be passed to your parse function and then used with your interp function with a suitable expression that calls it:
deffun neg? x
It must return either if the input is negative or if not The number is not itself considered negative.
Multiplication on integers
As you did in the previous problem, implement in the fnWAE language without any extensions a function mult that computes the product of two integers.
deffun mult x y
Handin instructions
Provide definitions for parse, parsedefn, and interpexpr, as above.
Provide a PLAIlevel definition of multandnegdeffuns that is bound to a list of unparsed deffuns that contains both neg? and mult as well as any helper functions you need:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
