Read an expression, transform it, and print the result. ( 1 oop (print prompt (print (funcall transformer
Question:
"Read an expression, transform it, and print the result."
( 1 oop
(print prompt
(print (funcall transformer (read)))))
This function could then be used in writing each new interpreter:
(defun lisp 0
(interactive-interpreter '> #'eval))
(defun eliza 0
(interactive-interpreter 'eliza>
#'(lambda (x) (flatten (use-eliza-rules x)))))
Or, with the help of the higher-order function compose:
(defun compose (f g)
"Return the function that computes (f (g XI)."
#'(lambda (x) (funcall f (funcall g x))))
(defun eliza 0
(interactive-interpreter 'eliza>
(compose #'flatten #'use-eliza-rules)))
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Paradigms Of Artificial Intelligence Programming Case Studies In Common Lisp
ISBN: 9781558601918
1st Edition
Authors: Peter Norvig
Question Posted: