<commit_before>(import (only: (module) identifier?)) ;; TODO It might be good to
                                      ;; remove this dependency

(export match)

(define (pattern-match-helper pattern message)
  (cond
   ((identifier? pattern)
    (list message))
   
   ((and (or (string? pattern)
             (null? pattern)
             (boolean? pattern)
             (number? pattern))
         (equal? message pattern))
    '())
   
   ((and (pair? pattern)
         (eq? 'quote (car pattern))
         (eq? message (cadr pattern)))
    '())

   ((and (pair? pattern)
         (pair? message))
    (let loop ((p pattern) (m message))
      (cond
       ((and (null? p)
             (null? m))
        '())

       ((and (pair? p)
             (pair? m))
        (let ((res (pattern-match-helper
                    (car p)
                    (car m))))
          (and res
               (append
                res
                (loop (cdr p)
                      (cdr m))))))

       ((and (not (pair? p))
             (not (pair? m)))
        (pattern-match-helper p m))

       (else
        #f))))

   (else
    #f)))


(syntax-begin
 
 (define (pattern-match-param-list mac-env env pattern)
   (let ((pattern (extract-syntactic-closure-list pattern 1)))
     (cond
      ((identifier? pattern)
       (list pattern))
      
      ((and (pair? pattern)
            (identifier=? mac-env 'quote env (car pattern)))
       '())
      
      ((pair? pattern)
       (append (pattern-match-param-list mac-env env (car pattern))
               (pattern-match-param-list mac-env env (cdr pattern))))
      
      (else
       '()))))
 <commit_msg>Fixed bug in match<commit_after>(import (only: (module) identifier?)) ;; TODO It might be good to
                                      ;; remove this dependency

(export match)

(define (pattern-match-helper pattern message)
  (cond
   ((identifier? pattern)
    (list message))
   
   ((and (or (string? pattern)
             (null? pattern)
             (boolean? pattern)
             (number? pattern))
         (equal? message pattern))
    '())
   
   ((and (pair? pattern)
         (eq? 'quote (car pattern))
         (eq? message (cadr pattern)))
    '())

   ((and (pair? pattern)
         (pair? message))
    (let loop ((p pattern) (m message))
      (cond
       ((and (null? p)
             (null? m))
        '())

       ((and (pair? p)
             (pair? m))
        (let ((res (pattern-match-helper
                    (car p)
                    (car m))))
          (and res
               (append
                res
                (loop (cdr p)
                      (cdr m))))))

       ((and (not (pair? p))
             (not (pair? m)))
        (pattern-match-helper p m))

       (else
        #f))))

   (else
    #f)))


(syntax-begin
 
 (define (pattern-match-param-list mac-env env pattern)
   (cond
    ((identifier? pattern)
     (list pattern))
    
    ((and (pair? pattern)
          (identifier=? mac-env 'quote env (car pattern)))
     '())
    
    ((pair? pattern)
     (append (pattern-match-param-list mac-env env (car pattern))
             (pattern-match-param-list mac-env env (cdr pattern))))
    
    (else
     '())))

{'fraction_non_alphanumeric': 0.14804469273743018, 'fraction_numerical': 0.00031036623215394165, 'mean_word_length': 1.4640672782874617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3460773', 'n_tokens_mistral': 964, 'n_tokens_neox': 928, 'n_words': 276}