<commit_before>(define sqrt-guess 0.0001)

(define (set-sqrt-guess! x)
  (define (iter a b)
    (if (= b 0)
        a
        (iter (/ a 10) (- b 1))))
  (! sqrt-guess (iter 1.0 x)))

(define (sqrt-2 x)
  (define (good-enough? guess)
    (< (abs (- (square guess) x)) sqrt-guess))
  (define (improve guess)
    (average-2 guess (/ x guess)))
  (define (sqrt-iter guess)
    (if (good-enough? guess)
        guess
        (sqrt-iter (improve guess))))
  (sqrt-iter 1.0))

(define (sqrt-n x e)
  (define (good? guess)
    (< (abs (- (expt guess e) x)) sqrt-guess))
  (define (improve guess exp)
    (* (/ 1.0 e) (+ (/ x (expt guess (- e 1))) (* (- e 1) guess))))
  (define (sqrt-iter guess exp)
    (if (good? guess)
        guess
        (sqrt-iter (improve guess exp) e)))
  (sqrt-iter x e))

(define (poly root lst)
  (define (poly-iter root product l)
    (if (nil? l)
        product
        (poly-iter root (+ (* product root) (car l)) (cdr l))))
  (poly-iter root 0.0 lst))

(define (average-2 x y)
    (/ (+ x y) 2))

(define (average x)
  (begin
    (define (average-iter l)
      (if (nil? l)
          0
          (+ (car l) (average-iter (cdr l)))))
      (/ (average-iter x) (length x) 1.0)))

(define (square x) (* x x))

(define (cube x) (* x x x))

(define remainder %)
(define mul *)
(define quotient /)

(define (add-rat x y)
  (make-rat (+ (* (numer x) (denom y))
               (* (numer y) (denom x)))
            (* (denom x) (denom y))))

(define (sub-rat x y)
  (make-rat (- (* (numer x) (denom y))
               (* (numer y) (denom x)))
            (* (denom x) (denom y))))

(define (mul-rat x y)
  (make-rat (* (numer x) (numer y))
            (* (denom x) (denom y))))

(define (div-rat x y)
  (make-rat (* (numer x) (denom y))
            (* (denom x) (numer y))))

(define (equal-rat? x y)
  (= (* (numer x) (denom y))
     (* (numer y) (denom x))))

 (define (gcd a b)
  (if (= b 0)
      a
      (gcd b (% a b))))

(define (make-rat n d)
  (cons n d))

(define (numer x)
  (let ((g (gcd (car x) (cdr x))))
    (/ (car x) g)))

(define (denom x)
  (let ((g (gcd (car x) (cdr x))))
    (/ (cdr x) g)))

(define (print-rat x)
  (display-string (numer x))
  (display-string "/")
  (display-string (denom x)))

(define one-half  (make-rat 1 2))
(define one-third (make-rat 1 3))

(define (even? n)
  (= (% n 2) 0))
(define (odd? n)
  (not (even? n)))

(define (abs x)
  (if (< x 0)
      (- x)
      x))

(define (expt b n)
  (define (expt-iter b counter product)
    (if (= counter 0)
        product
        (expt-iter b
                   (- counter 1)
                   (* b product))))
  (expt-iter b (if (null? n) 2 n) 1))

(define (factorial n)
  (define (fact-iter product counter max-count)
    (if (> counter max-count)
        product
        (fact-iter (* counter product)
                   (+ counter 1)
                   max-count)))
  (fact-iter 1 1 n))

(define (fast-expt b n)
  (cond ((= n 0)
         1)
        ((even? n)
         (square (fast-expt b (/ n 2))))
        (else
         (* b (fast-expt b (- n 1))))))

(define (smallest-divisor n)
  (define (find-divisor n test-divisor)
    (cond ((> (square test-divisor) n)
           n)
          ((divides? test-divisor n)
           test-divisor)
          (else (find-divisor
                 n
                 (+ test-divisor 1)))))
  (find-divisor n 2))

(define (divides? a b)
  (= (remainder b a) 0))

(define (prime? n)
  (= n (smallest-divisor n)))


(define (expmod base exp m)
  (cond ((= exp 0) 1)
        ((even? exp)
         (remainder
          (square (expmod base (/ exp 2) m))
          m))
        (else
         (remainder
          (* base (expmod base (- exp 1) m))
          m))))

(define pi 3.14159265359)<commit_msg>renamed poly to horner<commit_after>(define sqrt-guess 0.0001)

(define (set-sqrt-guess! x)
  (define (iter a b)
    (if (= b 0)
        a
        (iter (/ a 10) (- b 1))))
  (! sqrt-guess (iter 1.0 x)))

(define (sqrt-2 x)
  (define (good-enough? guess)
    (< (abs (- (square guess) x)) sqrt-guess))
  (define (improve guess)
    (average-2 guess (/ x guess)))
  (define (sqrt-iter guess)
    (if (good-enough? guess)
        guess
        (sqrt-iter (improve guess))))
  (sqrt-iter 1.0))

(define (sqrt-n x e)
  (define (good? guess)
    (< (abs (- (expt guess e) x)) sqrt-guess))
  (define (improve guess exp)
    (* (/ 1.0 e) (+ (/ x (expt guess (- e 1))) (* (- e 1) guess))))
  (define (sqrt-iter guess exp)
    (if (good? guess)
        guess
        (sqrt-iter (improve guess exp) e)))
  (sqrt-iter x e))

(define (horner root lst)
  (define (horner-iter root product l)
    (if (nil? l)
        product
        (horner-iter root (+ (* product root) (car l)) (cdr l))))
  (horner-iter root 0.0 lst))

(define (average-2 x y)
    (/ (+ x y) 2))

(define (average x)
  (begin
    (define (average-iter l)
      (if (nil? l)
          0
          (+ (car l) (average-iter (cdr l)))))
      (/ (average-iter x) (length x) 1.0)))

(define (square x) (* x x))

(define (cube x) (* x x x))

(define remainder %)
(define mul *)
(define quotient /)

(define (add-rat x y)
  (make-rat (+ (* (numer x) (denom y))
               (* (numer y) (denom x)))
            (* (denom x) (denom y))))

(define (sub-rat x y)
  (make-rat (- (* (numer x) (denom y))
               (* (numer y) (denom x)))
            (* (denom x) (denom y))))

(define (mul-rat x y)
  (make-rat (* (numer x) (numer y))
            (* (denom x) (denom y))))

(define (div-rat x y)
  (make-rat (* (numer x) (denom y))
            (* (denom x) (numer y))))

(define (equal-rat? x y)
  (= (* (numer x) (denom y))
     (* (numer y) (denom x))))

 (define (gcd a b)
  (if (= b 0)
      a
      (gcd b (% a b))))

(define (make-rat n d)
  (cons n d))

(define (numer x)
  (let ((g (gcd (car x) (cdr x))))
    (/ (car x) g)))

(define (denom x)
  (let ((g (gcd (car x) (cdr x))))
    (/ (cdr x) g)))

(define (print-rat x)
  (display-string (numer x))
  (display-string "/")
  (display-string (denom x)))

(define one-half  (make-rat 1 2))
(define one-third (make-rat 1 3))

(define (even? n)
  (= (% n 2) 0))
(define (odd? n)
  (not (even? n)))

(define (abs x)
  (if (< x 0)
      (- x)
      x))

(define (expt b n)
  (define (expt-iter b counter product)
    (if (= counter 0)
        product
        (expt-iter b
                   (- counter 1)
                   (* b product))))
  (expt-iter b (if (null? n) 2 n) 1))

(define (factorial n)
  (define (fact-iter product counter max-count)
    (if (> counter max-count)
        product
        (fact-iter (* counter product)
                   (+ counter 1)
                   max-count)))
  (fact-iter 1 1 n))

(define (fast-expt b n)
  (cond ((= n 0)
         1)
        ((even? n)
         (square (fast-expt b (/ n 2))))
        (else
         (* b (fast-expt b (- n 1))))))

(define (smallest-divisor n)
  (define (find-divisor n test-divisor)
    (cond ((> (square test-divisor) n)
           n)
          ((divides? test-divisor n)
           test-divisor)
          (else (find-divisor
                 n
                 (+ test-divisor 1)))))
  (find-divisor n 2))

(define (divides? a b)
  (= (remainder b a) 0))

(define (prime? n)
  (= n (smallest-divisor n)))


(define (expmod base exp m)
  (cond ((= exp 0) 1)
        ((even? exp)
         (remainder
          (square (expmod base (/ exp 2) m))
          m))
        (else
         (remainder
          (* base (expmod base (- exp 1) m))
          m))))

(define pi 3.1415926535897932)
(define piover180 0.0174532925199432957)
(define (deg2rad x) (* x piover180))
(define (rad2deg x) (/ x piover180))
{'fraction_non_alphanumeric': 0.1894088347096605, 'fraction_numerical': 0.021496919648708875, 'mean_word_length': 1.9200153080750095, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6761280', 'n_tokens_mistral': 3112, 'n_tokens_neox': 2884, 'n_words': 939}