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; <= 8 9; ---conformance--- 10; R5RS 11 12; ---purpose--- 13; Check whether a seqeunce of numbers is in strict 14; non-descending order. 15; Return 16; .C #t, 17; if 18; .V a<=b<=... 19; and otherwise 20; .C #f. 21 22; ---args--- 23; A - number 24; B... - numbers 25 26; ---keywords--- 27; <= function, not greater than, less than or equal to, 28; ordering, relation, comparison, predicate 29 30; ---see-also--- 31; digits, <, >, >=, n<= 32 33; ---example--- 34; (<= 9 9 10) => #t 35 36(define lteq #t) 37 38; (require "nullp.scm") ; null? 39(require "greater.scm") ; > 40(require "fold-left.scm") 41(require "neqp.scm") ; neq? 42 43; ---code--- 44(define (<= a . b) 45 (letrec 46 ((lteq 47 (lambda (a b) 48 (cond ((eq? a #t) #t) 49 ((> a b) #t) 50 (else b))))) 51 (cond ((null? b) 52 (bottom '(too few arguments to <=))) 53 (else (neq? (fold-left lteq a b) #t))))) 54