;;;; 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)) ; (define (fxzero? n) (fx= 0 n)) (: fxpositive? (fixnum --> boolean)) ; (define (fxpositive? n) (fx< 0 n)) (: fxnatural? (fixnum --> boolean)) ; (define (fxnatural? n) (fx<= 0 n)) (: fxnegative? (fixnum --> boolean)) ; (define (fxnegative? n) (fx> 0 n)) (: fxnon-positive? (fixnum --> boolean)) ; (define (fxnon-positive? n) (fx>= 0 n)) ;; (: fxclosed-right? (fixnum fixnum fixnum --> boolean)) ; (define (fxclosed-right? l x h) (and (fx< l x) (fx<= x h))) (: fxclosed? (fixnum fixnum fixnum --> boolean)) ; (define (fxclosed? l x h) (and (fx<= l x) (fx<= x h))) (: fxclosed-left? (fixnum fixnum fixnum --> boolean)) ; (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)) ;; (: fxabs (fixnum --> fixnum)) ; (define (fxabs n) (if (fxnegative? n) (fxneg n) n)) ;; (: fxadd1 (fixnum --> fixnum)) ; (define (fxadd1 n) (fx+ n 1)) (: fxsub1 (fixnum --> fixnum)) ; (define (fxsub1 n) (fx- n 1)) (: fxsqr (fixnum --> fixnum)) ; (define (fxsqr n) (fx* n n)) (: fxcub (fixnum --> fixnum)) ; (define (fxcub n) (fx* n (fx* n n))) ) ;fx-inlines