<commit_before>;; Define some boolean operators

(provide not boolean=? string=? equal? equal-seen)

(define (not x)
  (if x #f #t))


;; Check to see that both arguments are booleans
;; and equal
(define (boolean=? x y)
  (and (boolean? x) (boolean? y) (eq? x y)))

;; Check to see that both arguments are strings
;; and equal
;; TODO: This needs to be rewritten as scheme
(define (string=? x y)
  (and (string? x) (string? y) (eq? x y)))


;; break cycles in equal-pair?
;; TODO: This is very inefficient but will work
(define (equal-seen x seen-x)
  (cond
   ((null? seen-x) #f)
   ((eq? x (car seen-x)) #t)
   (else (equal-seen x (cdr seen-x)))))
      
	      


;; walk each the tree of pairs
;; TODO: This will have to change to deal with cycles
(define (equal-pair? x y)
  
  (define (equal-inner x y seen-x seen-y)
    (if (and (equal-seen x seen-x)
	     (equal-seen y seen-y))
	#t ;; We have a cyle

	(and
	 (if (and (pair? (car x)) (pair? (car y)))
	     (equal-inner (car x)
			  (car y)
			  (cons x seen-x) 
			  (cons y seen-y))
	     (equal? (car x) (car y)))

	 (if (and (pair? (cdr x)) (pair? (cdr y)))
	     (equal-inner (cdr x)
			  (cdr y)
			  (cons x seen-x) 
			  (cons y seen-y))
	     (equal? (cdr x) (cdr y))))))

  (equal-inner x y '() '()))
		    
		    

    

;; Check a pair of vectors for equality 
(define (equal-vector? x y)
  (let ((x (vector->list x))
	(y (vector->list y)))
	(equal-pair? x y)))
	   
  

;; Deep equality checking
(define (equal? x y)<commit_msg>Fixed a bug where () was not equal to itself<commit_after>;; Define some boolean operators

(provide not boolean=? string=? equal? equal-seen)

(define (not x)
  (if x #f #t))


;; Check to see that both arguments are booleans
;; and equal
(define (boolean=? x y)
  (and (boolean? x) (boolean? y) (eq? x y)))

;; Check to see that both arguments are strings
;; and equal
;; TODO: This needs to be rewritten as scheme
(define (string=? x y)
  (and (string? x) (string? y) (eq? x y)))


;; break cycles in equal-pair?
;; TODO: This is very inefficient but will work
(define (equal-seen x seen-x)
  (cond
   ((null? seen-x) #f)
   ((eq? x (car seen-x)) #t)
   (else (equal-seen x (cdr seen-x)))))
      
	      


;; walk each the tree of pairs
;; TODO: This will have to change to deal with cycles
(define (equal-pair? x y)
  
  (define (equal-inner x y seen-x seen-y)
    (cond 
     ((and (equal-seen x seen-x)
	   (equal-seen y seen-y)) #t) ;; We have a cyle

     ((and (null? x) (null? y)) #t) ;; we have two nulls

     (else (and
	    (if (and (pair? (car x)) (pair? (car y)))
		(equal-inner (car x)
			     (car y)
			     (cons x seen-x) 
			     (cons y seen-y))
		(equal? (car x) (car y)))

	    (if (and (pair? (cdr x)) (pair? (cdr y)))
		(equal-inner (cdr x)
			     (cdr y)
			     (cons x seen-x) 
			     (cons y seen-y))
		(equal? (cdr x) (cdr y)))))))

  (equal-inner x y '() '()))
		    
		    
;; Check a pair of vectors for equality 
(define (equal-vector? x y)
  (let ((x (vector->list x))
	(y (vector->list y)))
    (equal-pair? x y)))
	   
  
;; Deep equality checking
(define (equal? x y)
{'fraction_non_alphanumeric': 0.16741645244215939, 'fraction_numerical': 0.0, 'mean_word_length': 2.569954128440367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7271004', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1152, 'n_words': 456}