<commit_before>;;;
;;; Miscellaneous help functions
;;;

;; Return the smallest i where (string-ref STR i) = CH,
;; or #f if none.
(define char-index
  (lambda (str ch)
    (let ((L (string-length str)))
      (let loop ((i 0))
        (cond ((= i L) #f)
              ((char=? ch (string-ref str i)) i)
              (else (loop (+ i 1))))))))

;; Return string STR with special characters replaced by escape
;; sequences.  DELIMITER is one such special character.
(define string-escapify
  (lambda (delimiter str)
    (define escapify-one
      (lambda (c accum)
        (cond ((char=? c delimiter)
               `(#\\ ,c ,@accum))
              ((assv c '((#\newline #\\ #\n)
                         (#\Tab     #\\ #\t)))
               => (lambda (pair) (append (cdr pair) accum)))
              ((char-printable? c)
               (cons c accum))
              (else
               `(#\\ #\x
                     ,@(string->list (number->string (char->integer c) 16))
                     ,@accum)))))
    (list->string (foldr escapify-one '() (string->list str)))))

;; Return string STR escapified and surrounded by the character DELIMITER.
(define string-quotify
  (lambda (delimiter str)
    (let ((q (string delimiter)))
      (string-append q (string-escapify delimiter str) q))))

;; Display a line to PORT, the concatenation of ARGS.
(define say-to
  (lambda (port . args)
    (for-each (lambda (arg) (display arg port))
              args)
    (newline port)))

;; SAY-TO stdout.
(define say
  (lambda args
    (apply say-to (cons (current-output-port) args))))

;; Add a pair to an association list.
(define acons<commit_msg>proper name for tab character<commit_after>;;;
;;; Miscellaneous help functions
;;;

;; Return the smallest i where (string-ref STR i) = CH,
;; or #f if none.
(define char-index
  (lambda (str ch)
    (let ((L (string-length str)))
      (let loop ((i 0))
        (cond ((= i L) #f)
              ((char=? ch (string-ref str i)) i)
              (else (loop (+ i 1))))))))

;; Return string STR with special characters replaced by escape
;; sequences.  DELIMITER is one such special character.
(define string-escapify
  (lambda (delimiter str)
    (define escapify-one
      (lambda (c accum)
        (cond ((char=? c delimiter)
               `(#\\ ,c ,@accum))
              ((assv c '((#\newline #\\ #\n)
                         (#\tab     #\\ #\t)))
               => (lambda (pair) (append (cdr pair) accum)))
              ((char-printable? c)
               (cons c accum))
              (else
               `(#\\ #\x
                     ,@(string->list (number->string (char->integer c) 16))
                     ,@accum)))))
    (list->string (foldr escapify-one '() (string->list str)))))

;; Return string STR escapified and surrounded by the character DELIMITER.
(define string-quotify
  (lambda (delimiter str)
    (let ((q (string delimiter)))
      (string-append q (string-escapify delimiter str) q))))

;; Display a line to PORT, the concatenation of ARGS.
(define say-to
  (lambda (port . args)
    (for-each (lambda (arg) (display arg port))
              args)
    (newline port)))

;; SAY-TO stdout.
(define say
  (lambda args
    (apply say-to (cons (current-output-port) args))))

;; Add a pair to an association list.
(define acons
{'fraction_non_alphanumeric': 0.15575757575757576, 'fraction_numerical': 0.0024242424242424242, 'mean_word_length': 2.099530516431925, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6395629', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1004, 'n_words': 351}