Evaluate the arithmetic expressions

Assignment Help Programming Languages
Reference no: EM13707333

You need to prepare a Lisp program to evaluate the arithmetic expressions.

Write a Lisp program to evaluate Lisp arithmetic expressions. Assume four operators may be used in expressions and they are +, -, *, and /. All these operators are binary, i.e., they are applied in an expression in this format: (operator operand1 operand2), where "operator" can be +, -, *, or /, and each operand can be either a single number, or another expression.

For case, the subsequent are all legal input:

(+ 1 2)

(- 6 (/ 7 0.5))

(* (/ 78 (- 67 3.5)) (+ 4 9.0))

But the following are not:

(+ 1) ; missing operand

(6 - 7) ; every expression must start with an operator

(/ + 4 5) ; every expression can only have one operator

(* 6 7 8) ; every expression must have exactly two operands

(% 6 7 ) ; unrecognizable operator

(- 6 A) ; illegal operator

Name the main function of your program "main". The given should be the way to run your program:

? (main '(+ 1 2))

3

where '(+ 1 2) is the input. If the input is legal, your program should output the final result of the expression evaluation, as given in the above case. If the input is illegal, the result is undefined, i.e., your program assumes the input is legal.

Reference no: EM13707333

Questions Cloud

Compute the mixture-averaged mass specific gibbs free energy : Using the thermodata computed from the matlab functions to compute the mixture-averaged mass specific Gibbs free energy of the final mixture, as a function of the progress variable (normalized as: 0 for no dissociation, and 1 for complete dissociatio..
What is the pressure change in the gas : A closed volume of 1 m3 of air (at sea level) is heated from 20°C to 400°C. Use the values for specific heat (cv =20.786 J/molK , cp= 29.1006 J/molK) and the specific gas constant R=8.31446 J/molK
Determine heat transferred to and word produced by steam : Steam at 75kPa and 13 percent quality is contained in a spring loaded piston-cylinder device with an initial volume of 3.90m^3. Steam is now heated until its volume is 9.75m^3 and its pressure is 300kPa. Determine the heat transferred to and the word..
Determine the mass flow rate of steam through the boiler : A steam power plant operates on an ideal reheat-regenerative Rankine cycle with one reheater and two open feed water heaters. Steam enters the high-pressure turbine at 1,500 psia and 1,100 degrees Farenheit and leaves the low-pressure turbine at 1 ps..
Evaluate the arithmetic expressions : Prepare a Lisp program to evaluate the arithmetic expressions - If the input is legal, your program should output the final result of the expression evaluation, as given in the above case. If the input is illegal, the result is undefined, i.e., you..
How you want to configure the clock input to the timer block : Clearly describe how you want to configure the clock input to the Timer block and what period value you will choose for the Timer block.
Evaluates and prints the value of the polynomial : Write a program that evaluates and prints the value of the polynomial ax2 + bx + c, given user inputs for a, b, c, and x using integers and floats.
Write an isr and startup code for a system : Write an ISR and startup code for a system that lights up LED0 on a PSoC Eval1 board (suppose that a wire is connecting P1[0]) to show "Low Voltage" whenever there is a supply voltage monitor interrupt.
What is the turnaround time for each process : Show the scheduling order of the processes using a Gantt chart and what is the turnaround time for each process?

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a statement that prints the message recall

Clunker Motors Inc. is recalling all vehicles from model years 1995-1998 and 2004-2006. Given a variable modelYear - Write a statement that prints the message "Recall" to standard output if the value of modelYear falls within those two ranges.

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Write program that prompts user to specify people and car

Write a C++ program that prompts the user to specify people and cars. Store them in a vector and a vector .

  Create a class named rectangle with length and width

To cover that floor with carpet that costs $8 per square foot would cost $960. (12 x 10 x8 = 960.). You should create a class named Rectangle with the following properties:

  Software system to manage records of patients

A software system is to be developed to manage the records of patients who enter a clinic for treatment. The records include records of the all regular patient monitoring.

  Create a class which holds account number

Create a class named Loan which holds the account number, name of account holder, amount borrowed, term, and interest rate. Include methods to set values for each data field.

  Develop two single dimension arrays-floating-point numbers

Develop two single dimension arrays which contain 10 floating-point numbers in each array. Develop third single dimension array to hold sum.

  Write the program by using ias instruction set

Using IAS instruction set, write the program for this problem. Ignore fact that IAS was designed to have only 1000 words of storage.

  Design class named loan that holds account number

Design a class named Loan that holds account number, name of account holder, amount borrowed, term, and interest rate. Include methods to set values for each data field.

  Write iterative program which finds largest number

Write the iterative program which finds largest number of McNuggets which cannot be bought in exact quantity. Your program must print the answer in the following format.

  Two-level memory cache hierarchy

Explain how you would pipeline the four following pairs of statements.

  Design getter and setter and constructor methods

User must have option to draw new shape at different location and keep the existing shape. Design all the getter and setter & constructor methods for each class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd