Added a few more functions

This commit is contained in:
Justin Ethier 2016-01-27 23:00:18 -05:00
parent d405c749ca
commit b9e0db08f2

View file

@ -7,6 +7,10 @@
max max
min min
modulo modulo
floor-remainder
even?
; exact-integer?
odd?
call-with-current-continuation call-with-current-continuation
call/cc call/cc
call-with-values call-with-values
@ -100,6 +104,7 @@
round round
exact exact
inexact inexact
;;;; ;;;;
; Possibly missing functions: ; Possibly missing functions:
; ;
@ -122,7 +127,6 @@
; ;error-object? ; ;error-object?
; ;file-error? ; ;file-error?
; ;floor-quotient ; ;floor-quotient
; ;floor-remainder
; ;floor/ ; ;floor/
; ;guard ; ;guard
; ;import ; ;import
@ -172,9 +176,7 @@
; eq? ; eq?
; equal? ; equal?
; eqv? ; eqv?
; even?
; exact-integer-sqrt ; exact-integer-sqrt
; exact-integer?
; exact? ; exact?
; expt ; expt
; foldl ; foldl
@ -201,7 +203,6 @@
; number->string ; number->string
; number? ; number?
; numerator ; numerator
; odd?
; open-input-bytevector ; open-input-bytevector
; open-input-string ; open-input-string
; open-output-bytevector ; open-output-bytevector
@ -863,6 +864,11 @@
make_int(result, i % j); make_int(result, i % j);
return_closcall1(data, k, &result); return_closcall1(data, k, &result);
}") }")
(define floor-remainder modulo)
(define (odd? num) (= (modulo num 2) 1))
(define (even? num) (= (modulo num 2) 0))
; TODO: (define (exact-integer? num)
; TODO: (and (exact? num) (integer? 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))
)) ))