picrin/etc/tak.scm

27 lines
435 B
Scheme
Raw Normal View History

(import (scheme base)
(scheme time)
(scheme write))
2013-10-28 09:08:57 -04:00
(define (time f)
2013-11-04 13:19:04 -05:00
(let ((start (current-jiffy)))
(f)
2015-06-27 15:13:12 -04:00
(inexact
(/ (- (current-jiffy) start)
(jiffies-per-second)))))
2013-10-28 09:08:57 -04:00
(define (tak x y z)
(if (> x y)
2013-11-04 13:19:04 -05:00
(tak (tak (- x 1) y z)
2013-10-28 09:08:57 -04:00
(tak (- y 1) z x)
(tak (- z 1) x y))
y))
(define (f)
(tak 12 6 0))
(write-simple (time f))
2013-11-04 13:19:04 -05:00
(newline)
2013-11-04 20:37:51 -05:00
; 70fb34 -> 10.374959
; fb6679 -> 4.275342