Emacs part13
レス数が950を超えています。1000を超えると書き込みができなくなります。
0977名無しさん@お腹いっぱい。
2005/03/26(土) 00:38:16(progn
(defun power (n x &optional r)
(setq r (or r 1))
(cond ((= x 0) r)
((= x 1) (* n r))
(t (power (* n n) (/ x 2) (* (power n (% x 2)) r)))))
(defun power_cps (c n x &optional r)
(setq r (or r 1))
(cond ((= x 0) `(lambda () (funcall ,c ,r)))
((= x 1) `(lambda () (funcall ,c ,(* n r))))
(t `(lambda ()
(power_cps (lambda (y)
(power_cps ,c ,(* n n) ,(/ x 2) (* ,r y)))
,n ,(% x 2))))))
(defun run_power (n x) (power n x))
(defun run_power_cps (n x)
(let ((c (power_cps (lambda (x) x) n x)))
(while (functionp c) (setq c (funcall c)))
c))
(dolist (f '(power power_cps run_power run_power_cps)) (byte-compile f))
(elp-instrument-list '(run_power run_power_cps))
(let ((n 10.0) (x 100))
(dotimes (i 1000)
(run_power n x)
(run_power_cps n x)))
(elp-results))
Function Name Call Count Elapsed Time Average Time
============= ========== ============ ============
run_power_cps 1000 0.1459280000 0.0001459280
run_power 1000 0.0115380000 1.153...e-05
レス数が950を超えています。1000を超えると書き込みができなくなります。