{"size": 1209, "ext": "rktl", "max_stars_repo_path": "pkgs/racket-benchmarks/tests/racket/benchmarks/shootout/typed/random.rktl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-05T21:18:24.000Z", "max_stars_repo_stars_event_max_datetime": "2021-06-04T14:48:37.000Z", "max_issues_repo_path": "pkgs/racket-benchmarks/tests/racket/benchmarks/shootout/typed/random.rktl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-05-10T07:33:20.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-19T15:49:46.000Z", "max_forks_repo_path": "pkgs/racket-benchmarks/tests/racket/benchmarks/shootout/typed/random.rktl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": "2016-04-25T11:47:57.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-09T14:52:48.000Z"}
{"max_stars_count": 4, "max_issues_count": 9, "max_forks_count": 3, "avg_line_length": 30.225, "max_line_length": 72, "alphanum_fraction": 0.5401157982}
;;; http://shootout.alioth.debian.org/
;;; Random implementation, by Jens Axel Sogaard
;;;
;;; Modified for proper string output by Brent Fulgham
;;; Modified for Typed Scheme by Vincent St-Amour

(require (only-in mzlib/string real->decimal-string))

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

(define gen_random
  (let: ((LAST : Integer 42))
    (lambda: ((max : Float))
      (set! LAST (modulo (+ (* LAST IA) IC) IM))
      (/ (* max LAST) IM))))

(: roundto (Natural Float -> String))
(define (roundto digits num)
  (let*: ([e : Integer (expt 10 digits)]
          [num : Integer (round (* e (inexact->exact num)))])
    (format "~a.~a"
            (quotient num e)
            (substring (string-append (number->string (remainder num e))
                                      (make-string digits #\0))
                       0 digits))))

(let ((n (assert (string->number
                  (vector-ref (current-command-line-arguments)
                              0)) exact-integer?)))
  (let loop ((iter n))
    (if (> iter 1)
        (begin
          (gen_random 100.0)
          (loop (- iter 1)))
        #t))
  (printf "~a\n"
          (real->decimal-string (gen_random 100.0) 9)))
