Added exact? inexact? exact-integer?

This commit is contained in:
Justin Ethier 2016-01-28 22:46:29 -05:00
parent b9e0db08f2
commit 510c5ec2a7

View file

@ -9,7 +9,9 @@
modulo modulo
floor-remainder floor-remainder
even? even?
; exact-integer? exact-integer?
exact?
inexact?
odd? odd?
call-with-current-continuation call-with-current-continuation
call/cc call/cc
@ -177,7 +179,6 @@
; equal? ; equal?
; eqv? ; eqv?
; exact-integer-sqrt ; exact-integer-sqrt
; exact?
; expt ; expt
; foldl ; foldl
; foldr ; foldr
@ -185,7 +186,6 @@
; get-output-bytevector ; get-output-bytevector
; get-output-string ; get-output-string
; include ; include
; inexact?
; input-port-open? ; input-port-open?
; input-port? ; input-port?
; integer->char ; integer->char
@ -867,8 +867,15 @@
(define floor-remainder modulo) (define floor-remainder modulo)
(define (odd? num) (= (modulo num 2) 1)) (define (odd? num) (= (modulo num 2) 1))
(define (even? num) (= (modulo num 2) 0)) (define (even? num) (= (modulo num 2) 0))
; TODO: (define (exact-integer? num) (define (exact-integer? num)
; TODO: (and (exact? num) (integer? num))) (and (exact? num) (integer? num)))
(define-c exact?
"(void *data, int argc, closure _, object k, object num)"
" Cyc_check_num(data, num);
if (type_of(num) == integer_tag)
return_closcall1(data, k, boolean_t);
return_closcall1(data, k, boolean_f); ")
(define (inexact? num) (not (exact? num)))
(define (max first . rest) (foldl (lambda (old new) (if (> old new) old new)) first rest)) (define (max first . rest) (foldl (lambda (old new) (if (> old new) old new)) first rest))
(define (min first . rest) (foldl (lambda (old new) (if (< old new) old new)) first rest)) (define (min first . rest) (foldl (lambda (old new) (if (< old new) old new)) first rest))
)) ))