<commit_before>;;; heapsort.scm

;; Prints 0.9990640717878372 instead of 0.9990640718 when n=1000.
;; Updated by <NAME>
;;
;; Updated by <NAME> to provide proper output formatting

(require (only-in srfi/13 string-index string-pad-right)
         (only-in mzlib/string real->decimal-string))

(define IM   139968)
(define IA     3877)
(define IC    29573)

(: LAST Natural)
(define LAST 42)
(: gen_random (Float -> Float))
(define (gen_random max)
  (set! LAST (modulo (+ (* LAST IA) IC) IM))
  (/ (* max LAST) IM))

(: heapsort (Natural (Vectorof Float) -> (U Void True)))
(define (heapsort n ra)
  (let: ((ir : Natural n)
         (l : Natural (+ (quotient n 2) 1))
         (i : Natural 0)
         (j : Natural 0)
         (rra : Float 0.0))
    (let/ec: return : True
      (do: : Void
           ((bar : True #t))
           ((= 1 0))
        (cond ((> l 1)
               (set! l (assert (- l 1) exact-nonnegative-integer?))
               (set! rra (vector-ref ra l)))<commit_msg>Added a coercion to inexact to avoid the case: (* <float> 0) -> exact 0 which causes a segfault when the result is used with an unsafe-fl operation.<commit_after>;;; heapsort.scm

;; Prints 0.9990640717878372 instead of 0.9990640718 when n=1000.
;; Updated by <NAME>
;;
;; Updated by <NAME> to provide proper output formatting

(require (only-in srfi/13 string-index string-pad-right)
         (only-in mzlib/string real->decimal-string))

(define IM   139968)
(define IA     3877)
(define IC    29573)

(: LAST Natural)
(define LAST 42)
(: gen_random (Float -> Float))
(define (gen_random max)
  (set! LAST (modulo (+ (* LAST IA) IC) IM))
  (/ (* max (exact->inexact LAST)) IM))

(: heapsort (Natural (Vectorof Float) -> (U Void True)))
(define (heapsort n ra)
  (let: ((ir : Natural n)
         (l : Natural (+ (quotient n 2) 1))
         (i : Natural 0)
         (j : Natural 0)
         (rra : Float 0.0))
    (let/ec: return : True
      (do: : Void
           ((bar : True #t))
           ((= 1 0))
        (cond ((> l 1)
               (set! l (assert (- l 1) exact-nonnegative-integer?))
               (set! rra (vector-ref ra l)))
{'fraction_non_alphanumeric': 0.1550751879699248, 'fraction_numerical': 0.05827067669172932, 'mean_word_length': 2.4394184168012925, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 18, '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': '1086344', 'n_tokens_mistral': 845, 'n_tokens_neox': 739, 'n_words': 249}