{"size": 1881, "ext": "rktl", "max_stars_repo_path": "pkgs/racket-benchmarks/tests/racket/benchmarks/shootout/typed/lists.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/lists.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/lists.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": 37.62, "max_line_length": 91, "alphanum_fraction": 0.5066454014}
(require compatibility/mlist)
(define SIZE 10000)

(: sequence (Integer Integer -> (MListof Integer)))
(define (sequence start stop)
  (if (> start stop)
      '()
      (mcons start (sequence (+ start 1) stop))))

(: head-to-tail! ((MListof Integer) (MListof Integer)
                  -> (values (MListof Integer) (MListof Integer))))
(define (head-to-tail! headlist taillist)
  (when (null? taillist) (begin
                           (set! taillist (ann (mlist (mcar headlist)) (MListof Integer)))
                           (set! headlist (mcdr headlist))))
  (letrec: ((htt-helper : ((MListof Integer) -> Void)
                        (lambda (dest)
                          (when (not (null? headlist))
                            (let ((headlink headlist))
                              (set-mcdr! dest headlink)
                              (set! headlist (mcdr headlist))
                              (htt-helper headlink))))))
    (htt-helper taillist)
    (values headlist taillist)))

(: test-lists ( -> Integer))
(define (test-lists)
  (let*: ([L1 : (MListof Integer) (sequence 1 SIZE)]
          [L2 : (MListof Integer) (mappend L1 '())]
          [L3 : (MListof Integer) '()])
    (set!-values (L2 L3) (head-to-tail! L2 L3))
    (set!-values (L3 L2) (head-to-tail! (mreverse! L3) L2))
    (set! L1 (mreverse! L1))
    (cond ((not (= SIZE (mcar L1))) 0)
          ((not (equal? L1 L2))    0)
          (else           (mlength L1)))))

(: main ((Vectorof String) -> Void))
(define (main args)
  (let: ((result : Integer 0))
    (let loop ((counter (if (= (vector-length args) 0)
                            1
                            (assert (string->number (vector-ref args 0)) exact-integer?))))
      (when (> counter 0)
        (set! result (test-lists))
        (loop (- counter 1))))
    (printf "~s\n" result)))

(main (current-command-line-arguments))
