[Openmcl-devel] inverse function

Raffael Cavallaro raffaelcavallaro at mac.com
Sat Feb 13 16:19:25 UTC 2010


On Feb 13, 2010, at 7:20 AM, Taoufik Dachraoui wrote:

> Does someone know if there is any work done to generate an inverse of any given lisp function (if possible).

1. Side effects:

(defun had-a-great-fall (being)
   (break-into-a-million-tiny-pieces being))

(inverse #'had-a-great-fall) => #'put-together-again

(defparameter *humpty-dumpty* (make-instance 'being :name "humpty-dumpty"))
=>*HUMPTY-DUMPTY*

(funcall (inverse #'had-a-great-fall) (had-a-great-fall *humpty-dumpty*)) 
=> error: all the king's horses and all the kings men couldn't
put #<BEING #x3020015339FD>, humpty-dumpty, together again.

i.e., common lisp has side effects, some of which can't be undone.

2. Functions can produce the same value for different args:

(defun square (x)
   (* x x))

(inverse #'square) => #'sqrt ;; or something very like sqrt

(funcall (inverse #'square) (square -3)) => 3 ;; i.e., not -3 as it you want it to


warmest regards,

Ralph


Raffael Cavallaro
raffaelcavallaro at me.com








More information about the Openmcl-devel mailing list