A lisp function that generates a random day of the week, then displays a message saying that "Today is ... and tomorrow will be ...". For this purpose, create a global variable before the function containing the days of the week as a list. Then use the built-in function random first to generate a number between 0 and 6 (including). The expression (random) by itself generates a random integer. You can call it with one parameter to return a value within the range from 0 to the value of the parameter-1. For example, (random 10) will return a value between 0 and 9. Next, use the number generated at the previous step to retrieve the symbol for the day of the week from the list. Use the built-in elt function. We want the name of the day to appear capitalized. For this, extract the symbol-name of the day first, then apply the built-in function capitalize to it. Use the result in the princ function call, and do the same thing for the next day. Make the function return true (t) instead of the last thing it evaluates, to avoid seeing the message printed more than once.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Question

Help with a lisp function 

(please post photos) 

 

A lisp function that generates a random day of the week, then displays a message saying that "Today is ... and tomorrow will be ...".

For this purpose, create a global variable before the function containing the days of the week as a list.

Then use the built-in function random first to generate a number between 0 and 6 (including). The expression (random) by itself generates a random integer. You can call it with one parameter to return a value within the range from 0 to the value of the parameter-1. For example, (random 10) will return a value between 0 and 9.

Next, use the number generated at the previous step to retrieve the symbol for the day of the week from the list. Use the built-in elt function.

We want the name of the day to appear capitalized. For this, extract the symbol-name of the day first, then apply the built-in function capitalize to it. Use the result in the princ function call, and do the same thing for the next day.

Make the function return true (t) instead of the last thing it evaluates, to avoid seeing the message printed more than once.

Expert Solution
Step 1 Introduction

In Lisp, a function which refers to the one it is a piece of code that performs a specific task. It is defined using the defun macro and consists of a list of parameters, followed by a body of code, which is executed when the function is called. The parameters are variables that are passed to the function when it is called. The code which it is in the body of the function is executed using the values of the parameters.

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr