;;;; ;; Issues ;; ;; - `bigO' "near" 1. should be rounded for comparisons (module bigO (;export bigO bigO= bigO< bigO> bigO-compare) (import scheme) ;;; (define (log-with-base b) (let ((lnb (log b))) (lambda (n) (/ (log n) lnb) ) ) ) (define log10 (log-with-base 10)) ;;; ;; ;#; ;over fit? (define (bigO a) (inexact->exact (round (log10 a)))) #; ;power 10 boundary issue - bigO 1000 3.0 floor -> 2.0 (define (bigO a) (import (only (chicken base) print)) (print "bigO " a " " (log10 a) " " (floor (log10 a)) " " (inexact->exact (floor (log10 a))) ) (let* ((a1 (log10 a)) (a2 (floor (log10 a))) (a3 (inexact->exact (floor (log10 a)))) ) (print "bigO " a " " a1 " " a2 " " a3) ) (inexact->exact (floor (log10 a)))) (define (bigO-compare a b) (- (bigO a) (bigO b))) (define (bigO< a b) (negative? (bigO-compare a b))) (define (bigO= a b) (zero? (bigO-compare a b))) (define (bigO> a b) (positive? (bigO-compare a b))) ) ;module bigO