Changeset 29315 in project


Ignore:
Timestamp:
07/06/13 20:59:15 (8 years ago)
Author:
sjamaan
Message:

Add boolean=? to r7rs, and export 'not' and 'boolean?'

Location:
release/4/r7rs/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/r7rs/trunk/scheme.base-interface.scm

    r29104 r29315  
    1010  begin
    1111  binary-port?
     12  |#
    1213  boolean? boolean=?
     14  #|
    1315  bytevector-append bytevector-copy bytevector-copy!
    1416  bytevector-length bytevector-u8-ref bytevector-u8-set!
     
    114116  negative? positive?
    115117  newline
     118  |#
    116119  not
     120  #|
    117121  null?
    118122  number->string string->number
  • release/4/r7rs/trunk/scheme.base.scm

    r29135 r29315  
    101101(include "synrules.scm")
    102102
     103
     104;;;
     105;;; 6.3 Booleans
     106;;;
     107
     108;(: boolean=? ((procedure #:enforce) (boolean boolean #!rest boolean) boolean))
     109(: boolean=? (boolean boolean #!rest boolean -> boolean))
     110
     111(define (boolean=? b1 b2 . rest)
     112  ;; Loop across all args, checking for booleans.  Don't shortcut and
     113  ;; stop when we find nonequality.
     114  (let lp ((b1 b1)
     115           (b2 b2)
     116           (rest rest)
     117           (result (eq? b1 b2)))
     118    (##sys#check-boolean b1 'boolean=?)
     119    (##sys#check-boolean b2 'boolean=?)
     120    (if (null? rest)
     121        (and result (eq? b1 b2))
     122        (lp b2 (car rest) (cdr rest) (and result (eq? b1 b2))))))
     123
     124
    103125;;;
    104126;;; 6.11. Exceptions
     
    211233(define (eof-object) #!eof)
    212234
    213 
    214235)
  • release/4/r7rs/trunk/tests/run.scm

    r29104 r29315  
    1717 (test #f (read-from-string "#false"))
    1818 (test-error (read-from-string "#faux")))
     19
     20(test-group "boolean=?"
     21  (test #t (boolean=? #t #t))
     22  (test #t (boolean=? #t #t #t #t))
     23  (test #t (boolean=? #f #f))
     24  (test #t (boolean=? #f #f #f #f))
     25  (test #f (boolean=? #f #t))
     26  (test #f (boolean=? #f #t #t #t))
     27  (test #f (boolean=? #f #f #t #t))
     28  (test #f (boolean=? #f #f #f #t))
     29  (test #f (boolean=? #t #f #f #f))
     30  (test #f (boolean=? #t #f #f #t))
     31  (test #f (boolean=? #t #t #f #t))
     32  (test #f (boolean=? #f #f #f #t))
     33  (test #f (boolean=? #f #t #f #f))
     34  (test-error (boolean=? #f))
     35  (test-error (boolean=? #f 1))
     36  (test-error "no shortcutting" (boolean=? #f #t 2)))
    1937
    2038(define-syntax catch
Note: See TracChangeset for help on using the changeset viewer.