Following example demonstrates ability to build function from the list in common lisp , execute this list to obtain definition of function; redefinition of function from the other list, executing redefinition for instantiation of the function.
SBCL was used.
-----------%<-------------
;; Copyright (c) Roman T. Gritsulyak, 2008,
;; echo "(append '(roman.gritsulyak) '(\@) '(gmail.com))" | clisp -q
Break 29 [33]> (defvar *my_fun*)
*MY_FUN*
Break 29 [33]> (setf *my_fun* (append '(defun) '(my(x)) '((* x x))))
(DEFUN MY (X) (* X X))
Break 29 [33]> (eval *my_fun*)
MY
Break 29 [33]> (my 5)
25
Break 29 [33]> (setf *my_fun* (append '(defun) '(my(x)) '((+ x x))))
(DEFUN MY (X) (+ X X))
Break 29 [33]> (my 5)
25
Break 29 [33]> (eval *my_fun*)
MY
Break 29 [33]> (my 5)
10
----------->%-------------
No comments:
Post a Comment