2007-05-05 04:20:42 -04:00
|
|
|
|
|
|
|
(library (ikarus fixnums)
|
2007-05-05 04:31:53 -04:00
|
|
|
(export fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx*)
|
2007-05-05 04:20:42 -04:00
|
|
|
(import
|
2007-05-05 04:31:53 -04:00
|
|
|
(only (scheme) $fxadd1 $fxsub1 $fxlognot $fx+ $fx- $fx*)
|
|
|
|
(except (ikarus) fxzero? fxadd1 fxsub1 fxlognot fx+ fx- fx*))
|
2007-05-05 04:20:42 -04:00
|
|
|
|
|
|
|
(define fxzero?
|
|
|
|
(lambda (x)
|
|
|
|
(cond
|
|
|
|
[(eq? x 0) #t]
|
|
|
|
[(fixnum? x) #f]
|
|
|
|
[else (error 'fxzero? "~s is not a fixnum" x)])))
|
|
|
|
|
|
|
|
(define fxadd1
|
|
|
|
(lambda (n)
|
|
|
|
(if (fixnum? n)
|
|
|
|
($fxadd1 n)
|
|
|
|
(error 'fxadd1 "~s is not a fixnum" n))))
|
|
|
|
|
|
|
|
(define fxsub1
|
|
|
|
(lambda (n)
|
|
|
|
(if (fixnum? n)
|
|
|
|
($fxsub1 n)
|
|
|
|
(error 'fxsub1 "~s is not a fixnum" n))))
|
|
|
|
|
2007-05-05 04:21:48 -04:00
|
|
|
(define fxlognot
|
|
|
|
(lambda (x)
|
|
|
|
(unless (fixnum? x)
|
|
|
|
(error 'fxlognot "~s is not a fixnum" x))
|
|
|
|
($fxlognot x)))
|
2007-05-05 04:31:53 -04:00
|
|
|
|
|
|
|
(define fx+
|
|
|
|
(lambda (x y)
|
|
|
|
(unless (fixnum? x)
|
|
|
|
(error 'fx+ "~s is not a fixnum" x))
|
|
|
|
(unless (fixnum? y)
|
|
|
|
(error 'fx+ "~s is not a fixnum" y))
|
|
|
|
($fx+ x y)))
|
|
|
|
|
|
|
|
(define fx-
|
|
|
|
(lambda (x y)
|
|
|
|
(unless (fixnum? x)
|
|
|
|
(error 'fx- "~s is not a fixnum" x))
|
|
|
|
(unless (fixnum? y)
|
|
|
|
(error 'fx- "~s is not a fixnum" y))
|
|
|
|
($fx- x y)))
|
|
|
|
|
|
|
|
(define fx*
|
|
|
|
(lambda (x y)
|
|
|
|
(unless (fixnum? x)
|
|
|
|
(error 'fx* "~s is not a fixnum" x))
|
|
|
|
(unless (fixnum? y)
|
|
|
|
(error 'fx* "~s is not a fixnum" y))
|
|
|
|
($fx* x y)))
|
|
|
|
|
|
|
|
|
2007-05-05 04:20:42 -04:00
|
|
|
)
|