Question: This version also allows the prompt to be either a string or a function of no arguments that will be called to print the prompt.

This version also allows the prompt to be either a string or a function of no arguments that will be called to print the prompt. The function prompt-generator, for example, returns a function that will print prompts of the form C11, C21, and so forth.

(defun i n t e r a c t i v e - i n t e r p r e t e r (prompt transformer)

"Read an expression, transform it, and p r i n t the r e s u l t ."

( 1 oop

(handl er-case

( progn

( i f (stringp prompt)

( p r i n t prompt)

(funcall prompt))

( p r i n t (funcall transformer ( r e a d ) ) ) )

;; I n case of e r r o r , do t h i s :

( e r r o r (condition)

(format t ""&;; Error "a ignored, back t o top l e v e l ."

c o n d i t i o n ) ) ) ) )

(defun prompt-generator (&optional (num 0) ( c t l - s t r i n g " [" dl "1)

"Return a function that p r i n t s prompts l i k e C11, C21, e t c ."

#'(lambda 0 (format t c t l - s t r i n g (incf num))))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Management And Artificial Intelligence Questions!

Q:

a