Changeset 10049 in project


Ignore:
Timestamp:
03/22/08 17:01:46 (12 years ago)
Author:
Kon Lovett
Message:

More dcl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/srfi-85/srfi-85.scm

    r2176 r10049  
    2424;;; EQUIV? and DAG-EQUIV?
    2525
    26 (declare (export equiv? dag-equiv?))
     26(eval-when (compile)
     27  (declare
     28    (not usual-integrations
     29      string=?
     30      eqv?)
     31    (no-procedure-checks)
     32    (export
     33      equiv?
     34      dag-equiv?) ) )
     35
     36(register-feature! 'srfi-85)
    2737
    2838;;;
     
    332342  (let ()
    333343
     344    ; Returns #t iff the object appears in the hash table.
     345
     346    (define (seen-previously? obj nodes)
     347      (hash-table-ref/default nodes obj #f))
     348 
     349    ; Increments the counter, and records its new value
     350    ; as the serial number for both arguments.
     351    ; Precondition:  Neither argument has a serial number.
     352
     353    (define (record-serial-numbers! x y)
     354      (set! counter (+ counter 1))
     355      (hash-table-set! xnodes x counter)
     356      (hash-table-set! ynodes y counter))
     357
     358    ; Returns #t iff x and y have the same serial number.
     359    ; If neither x nor y have been assigned a serial number,
     360    ; then their serial number is the current value of the
     361    ; counter.  In that case, the counter is incremented,
     362    ; and both x and y are entered into the hash tables.
     363
     364    (define (same-serial-number? x y)
     365      (let ((xid (hash-table-ref/default xnodes x #f))
     366            (yid (hash-table-ref/default ynodes y #f)))
     367        (cond ((and xid yid)
     368               (fx= xid yid))
     369              ((or xid yid)
     370               #f)
     371              (else
     372               (record-serial-numbers! x y)
     373               #t))))
     374
    334375    ; Returns #t iff x and y have the same graph structure.
    335376
     
    348389             (let ((nx (vector-length x))
    349390                   (ny (vector-length y)))
    350                (if (= nx ny)
     391               (if (fx= nx ny)
    351392                   (let loop ((i 0))
    352                      (if (< i nx)
     393                     (if (fx< i nx)
    353394                         (and (iso? (vector-ref x i)
    354395                                    (vector-ref y i))
    355                               (loop (+ i 1)))
     396                              (loop (fx+ i 1)))
    356397                         #t))
    357398                   #f)))
     
    363404             (eqv? x y))))
    364405
    365     ; Returns #t iff the object appears in the hash table.
    366 
    367     (define (seen-previously? obj nodes)
    368       (hash-table-ref/default nodes obj #f))
    369 
    370     ; Returns #t iff x and y have the same serial number.
    371     ; If neither x nor y have been assigned a serial number,
    372     ; then their serial number is the current value of the
    373     ; counter.  In that case, the counter is incremented,
    374     ; and both x and y are entered into the hash tables.
    375 
    376     (define (same-serial-number? x y)
    377       (let ((xid (hash-table-ref/default xnodes x #f))
    378             (yid (hash-table-ref/default ynodes y #f)))
    379         (cond ((and xid yid)
    380                (= xid yid))
    381               ((or xid yid)
    382                #f)
    383               (else
    384                (record-serial-numbers! x y)
    385                #t))))
    386  
    387     ; Increments the counter, and records its new value
    388     ; as the serial number for both arguments.
    389     ; Precondition:  Neither argument has a serial number.
    390 
    391     (define (record-serial-numbers! x y)
    392       (set! counter (+ counter 1))
    393       (hash-table-set! xnodes x counter)
    394       (hash-table-set! ynodes y counter))
    395 
    396406    (iso? x y)))
    397407
Note: See TracChangeset for help on using the changeset viewer.