1; SketchyLISP Library 2; Copyright (C) 2005,2006,2007 Nils M Holm. All rights reserved. 3; See the file LICENSE of the SketchyLISP distribution 4; for conditions of use. 5 6; ---name--- 7; zero? 8 9; ---conformance--- 10; R5RS 11 12; ---purpose--- 13; Test whether a number is zero. 14 15; ---args--- 16; X - number 17 18; ---keywords--- 19; ZERO? function, zero, numbers, digit, equivalence 20; identity, predicate 21 22; ---see-also--- 23; digits, even?, negative?, positive? 24 25; ---example--- 26; (zero? 0) => #t 27 28(define zerop #t) 29 30; (require "nullp.scm") ; null? 31(require "digits.scm") ; 0d 32(require "equal.scm") ; = 33 34; ---model--- 35; (define (zero? x) 36; (= x 0)) 37 38; ---code--- 39(define (zero? x) 40 (letrec 41 ((zerop 42 (lambda (list-x) 43 (cond ((eq? (car list-x) 0d) 44 (null? (cdr list-x))) 45 (else (= x 0)))))) 46 (zerop (integer->list x)))) 47