;;;; fx-inlines.scm -*- Scheme -*- ;;;; Kon Lovett, Jul '18 (module fx-inlines (;export fxzero? fxpositive? fxnatural? fxnegative? fxnon-positive? fxclosed-right? fxclosed? fxclosed-left? fxclosedr? fxclosedl? fxabs fxadd1 fxsub1 fxsqr fxcub) (import scheme) (import (chicken base)) (import (chicken fixnum)) (import (chicken type)) ;;; ;; (: fxzero? (fixnum -> boolean)) (: fxpositive? (fixnum -> boolean)) (: fxnatural? (fixnum -> boolean)) (: fxnegative? (fixnum -> boolean)) (: fxnon-positive? (fixnum -> boolean)) (: fxclosed-right? (fixnum fixnum fixnum -> boolean)) (: fxclosed? (fixnum fixnum fixnum -> boolean)) (: fxclosed-left? (fixnum fixnum fixnum -> boolean)) (: fxabs (fixnum -> fixnum)) (: fxadd1 (fixnum -> fixnum)) (: fxsub1 (fixnum -> fixnum)) (: fxsqr (fixnum -> fixnum)) (: fxcub (fixnum -> fixnum)) ;; (define (fxzero? n) (fx= 0 n)) (define (fxpositive? n) (fx< 0 n)) (define (fxnatural? n) (fx<= 0 n)) (define (fxnegative? n) (fx> 0 n)) (define (fxnon-positive? n) (fx>= 0 n)) ;; (define (fxclosed-right? l x h) (and (fx< l x) (fx<= x h))) (define (fxclosed? l x h) (and (fx<= l x) (fx<= x h))) (define (fxclosed-left? l x h) (and (fx<= l x) (fx< x h))) ;inline, remember (define (fxclosedr? l x h) (fxclosed-right? l x h)) (define (fxclosedl? l x h) (fxclosed-left? l x h)) ;; (define (fxabs n) (if (fxnegative? n) (fxneg n) n)) ;; (define (fxadd1 n) (fx+ n 1)) (define (fxsub1 n) (fx- n 1)) (define (fxsqr n) (fx* n n)) (define (fxcub n) (fx* n (fx* n n))) ) ;fx-inlines