- Scritto da:
> che sto per iniziare la solita sessione serale
> lispara e quindi creerò necessariamente thread
> nerdosi
(defun compose (f g)
"Composition of f after g."
(lambda (x) (funcall f (funcall g x))))
(defun square (x) (* x x))
(defun repeated (f n)
"Repeated application of f."
(if (zerop n)
#'identity
(compose f (repeated f (1- n)))))
(defun smooth-transform (f &optional (dx 0.5))
"Smooth transform of f."
(lambda (x) (/ (+ (funcall f (- x dx))
(funcall f x)
(funcall f (+ x dx)))
3.0)))
domanda:
(funcall (funcall (repeated #'smooth-transform 5) #'square) 3)
9.8333333
invece
(funcall (repeated (smooth-transform #'square) 5) 3)
2.525275e15
ESTICAZZI, subito non mi era chiaro il perché, ora invece lo è