Using Common Lisp create the following functions a. goodbye : It should print “b
ID: 3604056 • Letter: U
Question
Using Common Lisp create the following functions
a. goodbye: It should print “bye”, “good bye”, “farewell” or some other word.
b. middle-name: Accepts a full name as an argument and returns the middle name. This name can be represented as a list. For example, if you execute the program by entering “(middle-name ‘(Mary Jane Doe))” the output should be “Jane”.
c. second-of-second: Accepts a list of lists as an argument and returns the second element of the second list. For example, if you run the function by entering (second-of-second ‘((a b c) (1 x) (e f))) the output should be “x”.
d. repeater: You have the option of 1) printing the text of our choice a set number of times or 2) letting the user specify the number of times to print the text in an argument. You will receive more points for level of effort if you successfully complete the second option.
Explanation / Answer
d.
(defun repeater (num-times print-what)
(setf x 1)
(dotimes (counter num-times)
(write x)
(write print-what)
(terpri)
(incf x))
)
(repeater 6 '.IA)
/* output:-
c.
(defun sub(str)
(terpri)
(write-line (subseq str 5 9))
)
(sub "Mary Jane Doe")
/*output:-
*/
a.
(defun sub(str)
(terpri)
(write-line (subseq str 4))
(write-line str)
(write 'Farewell)
)
(sub "goodbye")
/*output:-
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.