[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

``Update functions'' in Scheme.



Kludge of the week:

(define (compose f g)
  (let ((the-composition
	 (lambda (x)
	   (f (g x)))))
    (if (has-setter? f)
	(declare-setter the-composition
			(let ((core (setter f)))
			  (lambda (new-value x)
			    (core new-value (g x))))))
    the-composition))

PS: Aren't first-class procedures fun? :-)