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

  Prepare console application to examine contents of text file

Prepare the C++ console application which examines the contents of a text file. Your program must count the number of: * lines (hint: use getline).

  Design program to ecode message using caesar cypher

Design a program which decodes messages. Messages will be encoded using Caesar cypher, with each letter being decoded by replacing it with previous letter in alphabet.

  Write pseudocode to accept candy name

Write a pseudocode for the following: A programm to accept a candy name (for exmple, "chocolate-covered blueberries'), price per pound, and number of pounds sold.

  Design a program using structured pseudocode

Design a program using structured pseudocode as demonstrated in the lectures and, ensuring all variables are declared, prompt the user for the appropriate input and display a meaningful output message.

  Develope a tutoring software for an elementary school

You are the project manger for a company that is planning to develope a tutoring software for an elementary school that will follow their curriculum create a work breadown structure.

  Program that produces the decompostion of integers

Give a program that produces the decompostion of integers between 0 and 121 using powers of 3(1, 3, 9, 27, 81) - play a particular role using any language

  Building instruction set simulators

Building Instruction Set Simulators

  How long will it take the program to run

How long will it take the program to run with 1000 processors, if each processor is as fast as the single processor on which the serial program was run?

  Write program to compute the volume flow rate

Write program to compute volume flow rate in cubic feet per second of water flowing through pipe of diameter d in inches and a velocity of v feet per second.

  Program to find if number input by user is palindrome or not

Write down the program which uses the method called palindrome ( ) to find out if number input by user is a palindrome or not. For instance 1221 is palindrome as it can be read same way forwards and backwards.

  Create visual basic windows application

Create Visual Basic Windows application. Use following names for solution and project, respectively: Raise Solution and Raise Project.

  Now an electric resistor placed in the tank is turned on

an insulated rigid tank initially contains 1.4-kg saturated liquid water and water vapor at 200degc. at this state 25

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