Answered step by step
Verified Expert Solution
Question
1 Approved Answer
GUIDELINES For each part you must: Write a LISP program Test, debug, and execute the LISP program a. b. 1. a) Write a function that
GUIDELINES For each part you must: Write a LISP program Test, debug, and execute the LISP program a. b. 1. a) Write a function that takes any two inputs and makes a list of them using CONS b) Write a function that takes four inputs and returns a two-element nested list. The first element should be a list of the first two inputs, and the second element a list of the last two inputs. c) Define a function MILES-PER-GALLON that takes three inputs, called INITIAL- ODOMETER-READING, FINAL-ODOMETER-READING, and GALLONS-CONSUMED and computes the number of miles traveled per gallon of gas. d) Write a predicate FIRSTP that returns T if its first argument (a symbol) is equal to the first element of its second argument (a list). That is, (FIRSTP 'Foo '(FOO BAR BAZ)) should return T. (FIRSTP 'BOING '(FOO BAR BAZ)) should return NIL e) Write a function MID-ADD1 that adds 1 to the middle element of a three-element list. For example, (MID-ADD (TAKE 2 COOKIES)) should return the list (TAKE 3 COOKIES). Note: You are not allowed to make MID-ADD1 a function of three inputs. It has to take a single input that is a list of three elements f) Write a function F-TO-C that converts a temperature from Fahrenheit to Celsius. The formula for doing the conversion is: Celsius temperature-5x (Fahrenheit temperature-32)/9. To go in the opposite direction, the formula is: Fahrenheit temperature -(9/5x Celsius temperature) + 32. GUIDELINES For each part you must: Write a LISP program Test, debug, and execute the LISP program a. b. 1. a) Write a function that takes any two inputs and makes a list of them using CONS b) Write a function that takes four inputs and returns a two-element nested list. The first element should be a list of the first two inputs, and the second element a list of the last two inputs. c) Define a function MILES-PER-GALLON that takes three inputs, called INITIAL- ODOMETER-READING, FINAL-ODOMETER-READING, and GALLONS-CONSUMED and computes the number of miles traveled per gallon of gas. d) Write a predicate FIRSTP that returns T if its first argument (a symbol) is equal to the first element of its second argument (a list). That is, (FIRSTP 'Foo '(FOO BAR BAZ)) should return T. (FIRSTP 'BOING '(FOO BAR BAZ)) should return NIL e) Write a function MID-ADD1 that adds 1 to the middle element of a three-element list. For example, (MID-ADD (TAKE 2 COOKIES)) should return the list (TAKE 3 COOKIES). Note: You are not allowed to make MID-ADD1 a function of three inputs. It has to take a single input that is a list of three elements f) Write a function F-TO-C that converts a temperature from Fahrenheit to Celsius. The formula for doing the conversion is: Celsius temperature-5x (Fahrenheit temperature-32)/9. To go in the opposite direction, the formula is: Fahrenheit temperature -(9/5x Celsius temperature) + 32
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started