#lang scheme/base
(require "base.ss")
(require "convert.ss")
(define (number+false? item)
(or (number? item) (not item)))
(define (integer+false? item)
(or (integer? item) (not item)))
(define (natural? num)
(and (integer? num)
(>= num 0)))
(define (natural+false? item)
(or (natural? item) (not item)))
(define (round-to num [places 0])
(let ([exp (for/fold ([accum 1])
([num (in-range 0 (abs places))])
(* accum 10))])
(if (>= places 0)
(/ (round (* (exact->inexact num) exp)) exp)
(round (* (round (/ (exact->inexact num) exp)) exp)))))
(provide symbol+false->number+false
number+false->symbol+false
string+false->number+false
number+false->string+false
natural->hex-string
hex-string->natural)
(provide/contract
[number+false? procedure?]
[integer+false? procedure?]
[natural? procedure?]
[natural+false? procedure?]
[round-to (->* (number?) (integer?) inexact?)])