<commit_before>;; Copyright (c) 2013-2014 by <NAME>, All Rights Reserved.

(define is_number number?)
(define is_integer integer?)
(define is_real real?)
(define is_rational rational?)
(define is_complex complex?)
(define is_exact exact?)
(define is_inexact inexact?)
(define is_zero zero?)
(define is_even even?)
(define is_odd odd?)
(define is_positive positive?)
(define is_negative negative?)
(define is_nan nan?)
(define is_fixnum fixnum?)
(define is_flonum flonum?)
(define is_fxnegative fxnegative?)
(define is_fxpositive fxpositive?)
(define is_fxzero fxzero?)
(define is_fxeven fxeven?)
(define is_fxodd fxodd?)
(define is_flfinite flfinite?)
(define is_flinfinite flinfinite?)
(define is_fleven fleven?)
(define is_flodd flodd?)
(define is_flinteger flinteger?)
(define is_flnan flnan?)
(define is_flzero flzero?)
(define is_flnegative flnegative?)
(define is_flpositive flpositive?)

(define inf +inf.0)
(define _inf -inf.0)
(define nan +nan.0)
(define _zero -0.)
(define zero 0.)

(define is_finite finite?)
(define is_infinite infinite?)
(define (is_positive_infinity n) (= n +inf.0))
(define (is_negative_infinity n) (= n -inf.0))

(define integer_to_char integer->char)
(define rational_to_real exact->inexact)
(define real_to_rational inexact->exact)
(define number_to_string number->string)

(define (real_to_integer n)
  (inexact->exact (round n)))

(define (integer_to_real n)
  (exact->inexact n))

(define fixnum_to_flonum fixnum->flonum)

(define rectangular make-rectangular)
(define polar make-polar)
(define real_part real-part)
(define imag_part imag-part)

(define add +)
(define sub -)
(define mult *)
(define div /)

(define (safe_div a b)
  (if (zero? b) +inf.0 (/ a b)))

(define fxadd fx+)
(define fxsub fx-)
(define fxmult fx*)
(define fxwrap_add fxwrap+)
(define fxwrap_sub fxwrap-)
(define fxwrap_mult fxwrap*)

(define fladd fl+)
(define flsub fl-)
(define flmult fl*)
(define fldiv fl/)

(define arithmetic_shift arithmetic-shift)
(define bitwise_merge bitwise-merge)
(define bitwise_and bitwise-and)
(define bitwise_ior bitwise-ior)
(define bitwise_xor bitwise-xor)
(define bitwise_not bitwise-not)
(define bit_count bit-count)
(define integer_length integer-length)
(define is_bit_set bit-set?)
(define is_any_bits_set any-bits-set?)
(define is_all_bits_set all-bits-set?)
(define first_bit_set first-bit-set)
(define extract_bit_field extract-bit-field)
(define is_bit_field_set test-bit-field?)
(define clear_bit_field clear-bit-field)
(define replace_bit_field replace-bit-field)
(define copy_bit_field copy-bit-field)

(define is_fxbit_set fxbit-set?)
(define fxarithmetic_shift fxarithmetic-shift)
(define fxarithmetic_shift_left fxarithmetic-shift-left)
(define fxarithmetic_shift_right fxarithmetic-shift-right)
(define fxbit_count)
(define fxfirst_bit_set fxfirst-bit-set)
(define fxwraparithmetic_shift fxwraparithmetic-shift)
(define fxwraparithmetic_shift_left fxwraparithmetic-shift-left)
(define fxwraparithmetic_shift_right fxwraplogical-shift-right)
(define fxwraplogical_shift_right fxwraplogical-shift-right)

(define is_number_eq =)
(define is_number_lt <)
(define is_number_gt >)
(define is_number_lteq <=)
(define is_number_gteq >=)

(define fx_is_eq fx=)
(define fx_is_lt fx<)
(define fx_is_gt fx>)
(define fx_is_lteq fx<=)
(define fx_is_gteq fx>=)

(define fl_is_eq fl=)
(define fl_is_lt fl<)
(define fl_is_gt fl>)
(define fl_is_lteq fl<=)
(define fl_is_gteq fl>=)

(define integer_sqrt integer-sqrt)
(define integer_nth_root integer-nth-root)

(define random_integer random-integer)
(define random_real random-real)
(define random_byte_array random-u8vector)

(define (default_random_source) default-random-source)
(define (set_default_random_source s) (set! default-random-source s))
(define random_source make-random-source)
(define is_random_source random-source?)
(define random_source_state random-source-state-ref)
(define random_source_set_state random-source-state-set!)
(define random_source_randomize random-source-randomize!)
(define random_source_pseudo_randomize random-source-pseudo-randomize!)
(define random_source_for_integers random-source-make-integers)
(define random_source_for_reals random-source-make-reals)
(define random_source_for_byte_arrays random-source-make-u8vectors)

(define (prime? n)
  (if (< n 4) (> n 1)
      (and (odd? n)
	   (let loop ((k 3))
	     (or (> (* k k) n)
		 (and (positive? (remainder n k))
		      (loop (+ k 2))))))))

(define is_prime prime?)
<commit_msg>bitwise functions.<commit_after>;; Copyright (c) 2013-2014 by <NAME>, All Rights Reserved.

(define is_number number?)
(define is_integer integer?)
(define is_real real?)
(define is_rational rational?)
(define is_complex complex?)
(define is_exact exact?)
(define is_inexact inexact?)
(define is_zero zero?)
(define is_even even?)
(define is_odd odd?)
(define is_positive positive?)
(define is_negative negative?)
(define is_nan nan?)
(define is_fixnum fixnum?)
(define is_flonum flonum?)
(define is_fxnegative fxnegative?)
(define is_fxpositive fxpositive?)
(define is_fxzero fxzero?)
(define is_fxeven fxeven?)
(define is_fxodd fxodd?)
(define is_flfinite flfinite?)
(define is_flinfinite flinfinite?)
(define is_fleven fleven?)
(define is_flodd flodd?)
(define is_flinteger flinteger?)
(define is_flnan flnan?)
(define is_flzero flzero?)
(define is_flnegative flnegative?)
(define is_flpositive flpositive?)

(define inf +inf.0)
(define _inf -inf.0)
(define nan +nan.0)
(define _zero -0.)
(define zero 0.)

(define is_finite finite?)
(define is_infinite infinite?)
(define (is_positive_infinity n) (= n +inf.0))
(define (is_negative_infinity n) (= n -inf.0))

(define (exact num)
  (if (exact? num) num
      (inexact->exact num)))

(define (inexact num)
  (if (inexact? num) num
      (exact->inexact num)))

(define integer_to_char integer->char)
(define number_to_string number->string)
(define fixnum_to_flonum fixnum->flonum)

(define rectangular make-rectangular)
(define polar make-polar)
(define real_part real-part)
(define imag_part imag-part)

(define add +)
(define sub -)
(define mult *)
(define div /)

(define (sub1 n) (- n 1))
(define (add1 n) (+ n 1))

(define (safe_div a b)
  (if (zero? b) +inf.0 (/ a b)))

(define fxadd fx+)
(define fxsub fx-)
(define fxmult fx*)
(define fxwrap_add fxwrap+)
(define fxwrap_sub fxwrap-)
(define fxwrap_mult fxwrap*)

(define fladd fl+)
(define flsub fl-)
(define flmult fl*)
(define fldiv fl/)

(define bitwise_arithmetic_shift arithmetic-shift)
(define bitwise_merge bitwise-merge)
(define bitwise_and bitwise-and)
(define bitwise_ior bitwise-ior)
(define bitwise_xor bitwise-xor)
(define bitwise_not bitwise-not)

(define (bitwise_if i1 i2 i3)
  (bitwise-ior 
   (bitwise-and i1 i2)
   (bitwise-and (bitwise-not i1) i3)))

(define (bitwise_bit_count i)
  (if (>= i 0) (bit-count i)
      (bitwise-not (bitwise_bit_count (bitwise-not i)))))

(define (is_bit_set i n) (bit-set? n i))

(define bitwise_length integer-length)

(define (bitwise_copy_bit i index bit)
  (if (not (or (= bit 1) (= bit 0)))
      (error "Bit flag must be either 0 or 1."))
  (if (= bit 1)
      (bitwise-ior i (arithmetic-shift 1 index))
      (bitwise-and i (bitwise-not (arithmetic-shift 1 index)))))

(define (assert-nonneg-int i msg)
  (if (or (not (integer? i)) (< i 0))
      (error msg i)))

(define (assert-bw-range start end)
  (assert-nonneg-int start "Start index must be a nonnegative integer.")
  (assert-nonneg-int end "End index must be a nonnegative integer.")
  (if (> start end)
      (error "End index is less that start index." start end)))
  
(define (bitwise_bit_field i start end)
  (assert-bw-range start end)
  (extract-bit-field (- end start) start i))

(define (bitwise_copy_bit_field to start end from)
  (assert-bw-range start end)
  (let* ((mask1 (arithmetic-shift -1 start))
         (mask2 (bitwise-not (arithmetic-shift -1 end)))
         (mask (bitwise-and mask1 mask2)))
    (bitwise_if mask (arithmetic-shift from start) to)))

(define (bitwise_rotate_bit_field n start end count)
  (assert-bw-range start end)
  (assert-nonneg-int count "Count field must be a nonnegative integer.")
  (let* ((width (- end start))
         (count (modulo count width))
         (field0 (bitwise_bit_field n start end))
         (field1 (arithmetic-shift field0 count))
         (field2 (arithmetic-shift field0 (- count width)))
         (field (bitwise-ior field1 field2)))
    (bitwise_copy_bit_field n start end field)))

(define (bitwise_reverse_bit_field n start end)
  (assert-bw-range start end)
  (let ((field (bitwise_bit_field n start end))
        (width (- end start)))
    (let loop ((old field)(new 0)(width width))
      (cond
       ((zero? width) (bitwise_copy_bit_field n start end new))
       (else (loop (arithmetic-shift old -1)
                   (bitwise-ior (arithmetic-shift new 1)
                                (bitwise-and old 1))
                   (sub1 width)))))))

(define is_any_bits_set any-bits-set?)
(define is_all_bits_set all-bits-set?)
(define bitwise_first_bit_set first-bit-set)

(define is_fxbit_set fxbit-set?)
(define fxarithmetic_shift fxarithmetic-shift)
(define fxarithmetic_shift_left fxarithmetic-shift-left)
(define fxarithmetic_shift_right fxarithmetic-shift-right)
(define fxbit_count)
(define fxfirst_bit_set fxfirst-bit-set)
(define fxwraparithmetic_shift fxwraparithmetic-shift)
(define fxwraparithmetic_shift_left fxwraparithmetic-shift-left)
(define fxwraparithmetic_shift_right fxwraplogical-shift-right)
(define fxwraplogical_shift_right fxwraplogical-shift-right)

(define is_number_eq =)
(define is_number_lt <)
(define is_number_gt >)
(define is_number_lteq <=)
(define is_number_gteq >=)

(define fx_is_eq fx=)
(define fx_is_lt fx<)
(define fx_is_gt fx>)
(define fx_is_lteq fx<=)
(define fx_is_gteq fx>=)

(define fl_is_eq fl=)
(define fl_is_lt fl<)
(define fl_is_gt fl>)
(define fl_is_lteq fl<=)
(define fl_is_gteq fl>=)

(define integer_sqrt integer-sqrt)
(define integer_nth_root integer-nth-root)

(define random_integer random-integer)
(define random_real random-real)
(define random_byte_array random-u8vector)

(define (default_random_source) default-random-source)
(define (set_default_random_source s) (set! default-random-source s))
(define random_source make-random-source)
(define is_random_source random-source?)
(define random_source_state random-source-state-ref)
(define random_source_set_state random-source-state-set!)
(define random_source_randomize random-source-randomize!)
(define random_source_pseudo_randomize random-source-pseudo-randomize!)
(define random_source_for_integers random-source-make-integers)
(define random_source_for_reals random-source-make-reals)
(define random_source_for_byte_arrays random-source-make-u8vectors)

(define (prime? n)
  (if (< n 4) (> n 1)
      (and (odd? n)
	   (let loop ((k 3))
	     (or (> (* k k) n)
		 (and (positive? (remainder n k))
		      (loop (+ k 2))))))))

(define is_prime prime?)

(define (logb x b) (/ (log x) (log b)))

{'fraction_non_alphanumeric': 0.12203112203112203, 'fraction_numerical': 0.007462007462007462, 'mean_word_length': 5.202031602708804, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 35, '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': '2460217', 'n_tokens_mistral': 4088, 'n_tokens_neox': 3975, 'n_words': 1079}