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 program to accept data for each student in school

Write the program which accepts data for each student in school- student ID, classroom number, and score on achievement test. Create program which lists total points scored for each of the 30 classrooms.

  Assume you have bought an old semi-furnished house and need

assume you have bought an old semi-furnished house and need to renovate it before moving in. generally renovation work

  Write application for university admissions office

Write an application for a university admissions office. Prompt the user for a student's High School Grade Point (for example 3.2) and an admission test score (value from 0 to 100).

  Design application that would output payment coupons

Design the application that would output 12 payment coupons for each of the 15 apartments in each of the 20 buildings. Each coupon should contain the building number.

  Write code for largest value of parking tickets

Without using any additional variables, and without changing the values of ndays or the elements of the parkingTickets array, write some code that results in mostTickets containing the largest value found in parkingTickets .

  Create application that uses two-dimensional arrays

Create the application that uses 2-dimensional arrays to keep track of 5 students' grades, with each student having 3 different classes. You require to ask user to enter grade for each of 5 students.

  Create a program to store assignment grades for student

The elementary school for which you are doing development work has asked you to create a program to store assignment grades for one student.

  Write a vhdl code for soda vending machine

Write a VHDL code that implements the above soda machine. You have to turn in the following: A state diagram showing the implementation of your design. Clearly show all the states and the conditions on which transitions occur.

  Why small to medium sized firm implement pki solution

Why would a small to medium sized firm implement a PKI solution? What are the characteristics required in using a password that will provide security protection for a company?

  Program which accepts candy name-price per pound

A program which accepts the candy name (for example, "chocolate-covered cherries"), price per pound, and number of pounds sol in average month, and displays item's data only if it is best-selling item.

  Write program to show percentage of calories come from fat

Write a program which asks user to enter number of calories and fat grams in a food item. The program must display percentage of the calories that come from fat.

  Write a code to find the mean-median and mode

Use computer program to write a code (choose any language)to find the mean, median, mode ,variance and standard deviation.

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