1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
; Copyright (c) 1993-2008 by Richard Kelsey. See file COPYING.
(xodd? 10)
(xodd? 5)
(define-local-syntax (define-primitive id nargs)
(let ((args (reverse (list-tail '(z y x) (- '3 nargs)))))
`(define (,id . ,args)
(call-primitively ,id . ,args))))
(define-primitive + 2)
(define-primitive - 2)
(define-primitive * 2)
(define-primitive < 2)
(define-primitive = 2)
(define (xodd? x)
(cond ((= 0 x)
#f)
((< 100 x) ; efficiency hack
(goto odd? (- x 100)))
((< 1000 x) ; efficiency hack
(goto xodd? (- x 100)))
(else
(goto xeven? (- x 1)))))
(define (xeven? x)
(cond ((= 0 x)
#t)
((< 100 x) ; efficiency hack
(goto xeven? (- x 100)))
(else
(goto xodd? (- x 1)))))
(define (odd? x)
(cond ((= 0 x)
#f)
((< 100 x) ; efficiency hack
(goto odd? (- x 100)))
(else
(goto even? (- x 1)))))
(define (even? x)
(cond ((= 0 x)
#t)
((< 100 x) ; efficiency hack
(goto even? (- x 100)))
(else
(goto odd? (- x 1)))))
|