This version also allows the prompt to be either a string or a function of no arguments

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. 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))))

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: