0
(defun div618 (p1 p2)
"golden split"
(let ((ratio '(0. 0.191 0.236 0.382 0.5 0.618 0.809 1.))
(price (lambda (r) (if (<= p1 p2) (+ p1 (* (- p2 p1) r)) (- p1 (* (- p1 p2) r))))))
(if (<= p1 p2)
(dolist (r (reverse ratio)) (format t "-------~d ~d-------~%" r (price r)))
(dolist (r ratio) (format t "-------~d ~d-------~%" r (price r))))))
(div618 1600 6000)如何在函數中定義內部函數?
*** - EVAL: undefined function PRICE
The following restarts are available:
USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'PRICE).
RETRY :R2 Retry
STORE-VALUE :R3 Input a new value for (FDEFINITION 'PRICE).
ABORT :R4 Abort main loop
爲什麼不能內部函數 「價格」 可以用嗎?
真誠!