Skip to content

Commit

Permalink
BREAKING CHANGE: remove order-of-magnitude
Browse files Browse the repository at this point in the history
Remove the order-of-magnitude function, bump version.

Use `order-of-magnitude` from `racket/math` instead; note that function
returns an off-by--1 result compared to this one.

I'm probably the only person who **might** be using this function, and I
don't even think I am using it.
  • Loading branch information
bennn committed Apr 29, 2018
1 parent eedbb5f commit 9a67494
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 39 deletions.
2 changes: 1 addition & 1 deletion info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
(define deps '("base" "math-lib" "pict-lib"))
(define build-deps '("rackunit-lib" "racket-doc" "scribble-lib" "scribble-doc" "rackunit-abbrevs"))
(define pkg-desc "Utility functions")
(define version "0.1")
(define version "0.2")
(define pkg-authors '(ben))
(define scribblings '(("scribblings/gtp-util.scrbl" ())))
30 changes: 0 additions & 30 deletions main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
[log2
(-> exact-nonnegative-integer? exact-nonnegative-integer?)]

[order-of-magnitude
(-> real? exact-nonnegative-integer?)]

[file-remove-extension
(-> path-string? path-string?)]
;; Removes a Racket-added extension from a filename.
Expand Down Expand Up @@ -260,12 +257,6 @@
[else
(loop (+ k 1))]))]))

(define (order-of-magnitude n)
(let loop ([upper 10] [acc 0])
(if (< n upper)
acc
(loop (* upper 10) (+ acc 1)))))

(define (save-pict fn p)
(define bm (pict->bitmap p))
(send bm save-file fn 'png))
Expand Down Expand Up @@ -527,27 +518,6 @@
(check-exn exn:fail:contract?
(λ () (log2 72))))

(test-case "order-of-magnitude"
(check-apply* order-of-magnitude
[0
==> 0]
[1
==> 0]
[5
==> 0]
[9
==> 0]
[10
==> 1]
[12.34
==> 1]
[999
==> 2]
[999.99999
==> 2]
[1032
==> 3]))

(test-case "file-remove-extension"
(check-equal? (file-remove-extension "foo_tab.gz") "foo.tab")
(check-equal? (file-remove-extension "a_b.c") "a.b"))
Expand Down
8 changes: 0 additions & 8 deletions scribblings/gtp-util.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
racket/contract
racket/path
(only-in racket/math natural?)
(prefix-in rkt: (only-in racket/math order-of-magnitude))
(only-in openssl/md5 md5))]

@(define (make-gtp-util-eval) (make-base-eval '(require gtp-util)))
Expand Down Expand Up @@ -110,13 +109,6 @@ If you think one of these functions should "graduate" to another library
Assumes @racket[n] is a power of 2.
}

@defproc[(order-of-magnitude [n real?]) natural?]{
Count the number of digits in the given number.

@(let-syntax ([order-of-magnitude (make-rename-transformer #'rkt:order-of-magnitude)])
@deprecated[#:what "function" @racket[order-of-magnitude]]{(from @racketmodname[racket/math])})
}

@defproc[(file-remove-extension [ps path-string?]) path-string?]{
Remove the extension from the given filename.
}
Expand Down

0 comments on commit 9a67494

Please sign in to comment.