diff --git a/collects/tests/racket/benchmarks/shootout/binarytrees.rkt b/collects/tests/racket/benchmarks/shootout/binarytrees.rkt index 335a5687e3..0061679996 100644 --- a/collects/tests/racket/benchmarks/shootout/binarytrees.rkt +++ b/collects/tests/racket/benchmarks/shootout/binarytrees.rkt @@ -1,22 +1,26 @@ +#lang racket/base + ;;; The Great Computer Language Shootout ;;; http://shootout.alioth.debian.org/ ;;; Derived from the Chicken variant by Sven Hartrumpf -#lang scheme/base -(require scheme/cmdline) -(define-struct node (left val right)) +(require racket/cmdline) + +(struct node (left val right)) ;; Instead of (define-struct leaf (val)): -(define (make-leaf val) (make-node #f val #f)) +(define (leaf val) (node #f val #f)) (define (leaf? l) (not (node-left l))) (define (leaf-val l) (node-val l)) (define (make item d) (if (= d 0) - (make-leaf item) + (leaf item) (let ((item2 (* item 2)) (d2 (- d 1))) - (make-node (make (- item2 1) d2) item (make item2 d2))))) + (node (make (- item2 1) d2) + item + (make item2 d2))))) (define (check t) (if (leaf? t) diff --git a/collects/tests/racket/benchmarks/shootout/chameneos.rkt b/collects/tests/racket/benchmarks/shootout/chameneos.rkt index a3ba6c9bea..d8fed470b8 100644 --- a/collects/tests/racket/benchmarks/shootout/chameneos.rkt +++ b/collects/tests/racket/benchmarks/shootout/chameneos.rkt @@ -1,11 +1,12 @@ +#lang racket/base + ;;; The Great Computer Language Shootout ;;; http://shootout.alioth.debian.org/ ;;; -;;; Uses PLT Scheme threads +;;; Uses Racket threads -#lang scheme/base -(require scheme/cmdline - scheme/match) +(require racket/cmdline + racket/match) (define (change c1 c2) (case c1 @@ -96,5 +97,3 @@ (go n '(blue red yellow)) (go n '(blue red yellow red yellow blue red yellow red blue)) (newline)) - - diff --git a/collects/tests/racket/benchmarks/shootout/fannkuch.rkt b/collects/tests/racket/benchmarks/shootout/fannkuch.rkt index f2ec465b88..9efe09505e 100644 --- a/collects/tests/racket/benchmarks/shootout/fannkuch.rkt +++ b/collects/tests/racket/benchmarks/shootout/fannkuch.rkt @@ -1,11 +1,12 @@ +#lang racket/base + ;; fannkuch benchmark for The Computer Language Shootout ;; Written by Dima Dorfman, 2004 ;; Slightly improved by Sven Hartrumpf, 2005-2006 ;; Ever-so-slightly tweaked for MzScheme by Brent Fulgham ;; PLT-ized for v4.0 by Matthew -#lang scheme/base -(require scheme/cmdline) +(require racket/cmdline) (define (fannkuch n) (let ([pi (list->vector diff --git a/collects/tests/racket/benchmarks/shootout/fasta.rkt b/collects/tests/racket/benchmarks/shootout/fasta.rkt index 0cab52428b..3a7d650ff0 100644 --- a/collects/tests/racket/benchmarks/shootout/fasta.rkt +++ b/collects/tests/racket/benchmarks/shootout/fasta.rkt @@ -1,3 +1,5 @@ +#lang racket/base + ;; The Great Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; @@ -6,8 +8,7 @@ ;; Derived from the Chicken variant, which was ;; Contributed by Anthony Borla -#lang scheme/base -(require scheme/cmdline) +(require racket/cmdline) (define +alu+ (bytes-append @@ -40,7 +41,7 @@ (let* ((ia 3877) (ic 29573) (im 139968) (last seed)) (lambda (max) (set! last (modulo (+ ic (* last ia)) im)) - (/ (* max last) im) ))) + (/ (* max last) im)))) ;; ------------------------------- diff --git a/collects/tests/racket/benchmarks/shootout/k-nucleotide.rkt b/collects/tests/racket/benchmarks/shootout/k-nucleotide.rkt index 3ff38a4f93..1a9888218c 100644 --- a/collects/tests/racket/benchmarks/shootout/k-nucleotide.rkt +++ b/collects/tests/racket/benchmarks/shootout/k-nucleotide.rkt @@ -1,8 +1,8 @@ +#lang racket/base + ;; The Computer Language Shootout ;; http://shootout.alioth.debian.org/ -#lang scheme/base - (define (all-counts len dna) (let ([table (make-hasheq)] [seq (make-string len)]) @@ -16,12 +16,10 @@ (define (write-freqs table) (let* ([content (hash-map table cons)] [total (exact->inexact (apply + (map cdr content)))]) - (for-each - (lambda (a) - (printf "~a ~a\n" - (car a) - (real->decimal-string (* 100 (/ (cdr a) total)) 3))) - (sort content (lambda (a b) (> (cdr a) (cdr b))))))) + (for ([a (sort content > #:key cdr)]) + (printf "~a ~a\n" + (car a) + (real->decimal-string (* 100 (/ (cdr a) total)) 3))))) (define (write-one-freq table key) (let ([cnt (hash-ref table key 0)]) @@ -33,9 +31,8 @@ (regexp-match #rx#"(?m:^>THREE.*$)" in) (let ([s (open-output-string)]) ;; Copy everything but newlines to s: - (let loop () - (when (regexp-match #rx#"\n" in 0 #f s) - (loop))) + (for ([l (in-bytes-lines in)]) + (write-bytes l s)) ;; Extract the string from s: (string-upcase (get-output-string s))))) @@ -48,8 +45,6 @@ (newline) ;; Specific sequences: -(for-each (lambda (seq) - (write-one-freq (all-counts (string-length seq) dna) - (string->symbol seq))) - '("GGT" "GGTA" "GGTATT" "GGTATTTTAATT" "GGTATTTTAATTTATAGT")) - +(for ([seq '("GGT" "GGTA" "GGTATT" "GGTATTTTAATT" "GGTATTTTAATTTATAGT")]) + (write-one-freq (all-counts (string-length seq) dna) + (string->symbol seq))) diff --git a/collects/tests/racket/benchmarks/shootout/mandelbrot-generic.rkt b/collects/tests/racket/benchmarks/shootout/mandelbrot-generic.rkt index 37b3526660..e59f70d1d8 100644 --- a/collects/tests/racket/benchmarks/shootout/mandelbrot-generic.rkt +++ b/collects/tests/racket/benchmarks/shootout/mandelbrot-generic.rkt @@ -1,4 +1,5 @@ -;; --------------------------------------------------------------------- +#lang racket/base + ;; The Great Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; @@ -16,8 +17,7 @@ ;; [(> (magnitude z) 2.0) 0] ;; [else (loop (add1 i) (+ (* z z) c))])))) -#lang scheme/base -(require scheme/cmdline) +(require racket/cmdline) (define +limit-sqr+ 4.0) diff --git a/collects/tests/racket/benchmarks/shootout/mandelbrot-unsafe.rkt b/collects/tests/racket/benchmarks/shootout/mandelbrot-unsafe.rkt index 1701322ce3..6e3f7ec84b 100644 --- a/collects/tests/racket/benchmarks/shootout/mandelbrot-unsafe.rkt +++ b/collects/tests/racket/benchmarks/shootout/mandelbrot-unsafe.rkt @@ -1,4 +1,5 @@ -;; --------------------------------------------------------------------- +#lang racket/base + ;; The Great Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; @@ -7,12 +8,11 @@ ;; ;; This version uses unsafe operations -#lang scheme/base -(require scheme/cmdline - scheme/require (for-syntax scheme/base) +(require racket/cmdline + racket/require (for-syntax racket/base) (filtered-in (lambda (name) (regexp-replace #rx"unsafe-" name "")) - scheme/unsafe/ops)) + racket/unsafe/ops)) (define +limit-sqr+ 4.0) diff --git a/collects/tests/racket/benchmarks/shootout/mandelbrot.rkt b/collects/tests/racket/benchmarks/shootout/mandelbrot.rkt index 866f69b707..d5261658c0 100644 --- a/collects/tests/racket/benchmarks/shootout/mandelbrot.rkt +++ b/collects/tests/racket/benchmarks/shootout/mandelbrot.rkt @@ -1,13 +1,13 @@ -;; --------------------------------------------------------------------- +#lang racket/base + ;; The Great Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; ;; Derived from the Chicken variant, which was ;; Contributed by Anthony Borla -#lang scheme/base -(require scheme/cmdline - scheme/flonum) +(require racket/cmdline + racket/flonum) (define +limit-sqr+ 4.0) diff --git a/collects/tests/racket/benchmarks/shootout/meteor.rkt b/collects/tests/racket/benchmarks/shootout/meteor.rkt index 6afdf3675d..a8f3e93091 100644 --- a/collects/tests/racket/benchmarks/shootout/meteor.rkt +++ b/collects/tests/racket/benchmarks/shootout/meteor.rkt @@ -1,3 +1,5 @@ +#lang racket/base + ;; The Computer Language Benchmarks Game ;; http://shootout.alioth.debian.org/ ;; @@ -7,8 +9,7 @@ ;; contributed by Matthew Flatt ;; optimized by Eli Barzilay -#lang scheme/base -(require scheme/cmdline scheme/list) +(require racket/cmdline) (define width 5) (define height 10) diff --git a/collects/tests/racket/benchmarks/shootout/nbody-generic.rkt b/collects/tests/racket/benchmarks/shootout/nbody-generic.rkt index 3311cc344e..e1dd5fc89c 100644 --- a/collects/tests/racket/benchmarks/shootout/nbody-generic.rkt +++ b/collects/tests/racket/benchmarks/shootout/nbody-generic.rkt @@ -1,4 +1,5 @@ -#!/usr/bin/mzscheme -qu +#lang racket/base + ;; The Computer Language Benchmarks Game ;; http://shootout.alioth.debian.org/ ;; @@ -6,7 +7,7 @@ ;; Patrick Frankenberger and Juho Snellman, but using only native Scheme ;; idioms like 'named let' and 'do' special form. ;; -;; Contributed by Anthony Borla, then converted for mzscheme +;; Contributed by Anthony Borla, then converted for Racket ;; by Matthew Flatt and Brent Fulgham #| @@ -16,8 +17,7 @@ Correct output N = 1000 is -0.169087605 |# -#lang scheme/base -(require scheme/cmdline) +(require racket/cmdline) ;; ------------------------------ ;; define planetary masses, initial positions & velocity diff --git a/collects/tests/racket/benchmarks/shootout/nbody-vec-generic.rkt b/collects/tests/racket/benchmarks/shootout/nbody-vec-generic.rkt index 3829e54cc7..b76945a309 100644 --- a/collects/tests/racket/benchmarks/shootout/nbody-vec-generic.rkt +++ b/collects/tests/racket/benchmarks/shootout/nbody-vec-generic.rkt @@ -1,4 +1,5 @@ -#!/usr/bin/mzscheme -qu +#lang racket/base + ;; The Computer Language Benchmarks Game ;; http://shootout.alioth.debian.org/ ;; @@ -6,7 +7,7 @@ ;; Patrick Frankenberger and Juho Snellman, but using only native Scheme ;; idioms like 'named let' and 'do' special form. ;; -;; Contributed by Anthony Borla, then converted for mzscheme +;; Contributed by Anthony Borla, then converted for Racket ;; by Matthew Flatt and Brent Fulgham #| @@ -16,8 +17,7 @@ Correct output N = 1000 is -0.169087605 |# -#lang scheme/base -(require scheme/cmdline) +(require racket/cmdline) ;; ------------------------------ ;; define planetary masses, initial positions & velocity diff --git a/collects/tests/racket/benchmarks/shootout/nbody-vec-unsafe.rkt b/collects/tests/racket/benchmarks/shootout/nbody-vec-unsafe.rkt index 0b7a40daa3..c0cacef496 100644 --- a/collects/tests/racket/benchmarks/shootout/nbody-vec-unsafe.rkt +++ b/collects/tests/racket/benchmarks/shootout/nbody-vec-unsafe.rkt @@ -1,4 +1,5 @@ -#!/usr/bin/mzscheme -qu +#lang racket/base + ;; The Computer Language Benchmarks Game ;; http://shootout.alioth.debian.org/ ;; @@ -6,7 +7,7 @@ ;; Patrick Frankenberger and Juho Snellman, but using only native Scheme ;; idioms like 'named let' and 'do' special form. ;; -;; Contributed by Anthony Borla, then converted for mzscheme +;; Contributed by Anthony Borla, then converted for Racket ;; by Matthew Flatt and Brent Fulgham ;; Made unsafe and optimized by Sam TH #| @@ -16,15 +17,14 @@ Correct output N = 1000 is -0.169087605 |# -#lang scheme/base -(require scheme/cmdline scheme/require - (only-in scheme/flonum flvector) - (for-syntax scheme/base) +(require racket/cmdline racket/require + (only-in racket/flonum flvector) + (for-syntax racket/base) (filtered-in (lambda (name) (regexp-replace #rx"unsafe-fl" name "fl")) - scheme/unsafe/ops)) + racket/unsafe/ops)) ;; ------------------------------ ;; define planetary masses, initial positions & velocity diff --git a/collects/tests/racket/benchmarks/shootout/nbody-vec.rkt b/collects/tests/racket/benchmarks/shootout/nbody-vec.rkt index b89c888698..a246054dd3 100644 --- a/collects/tests/racket/benchmarks/shootout/nbody-vec.rkt +++ b/collects/tests/racket/benchmarks/shootout/nbody-vec.rkt @@ -1,4 +1,5 @@ -#!/usr/bin/mzscheme -qu +#lang racket/base + ;; The Computer Language Benchmarks Game ;; http://shootout.alioth.debian.org/ ;; @@ -6,7 +7,7 @@ ;; Patrick Frankenberger and Juho Snellman, but using only native Scheme ;; idioms like 'named let' and 'do' special form. ;; -;; Contributed by Anthony Borla, then converted for mzscheme +;; Contributed by Anthony Borla, then converted for Racket ;; by Matthew Flatt and Brent Fulgham #| @@ -16,9 +17,8 @@ Correct output N = 1000 is -0.169087605 |# -#lang scheme/base -(require scheme/cmdline - scheme/flonum) +(require racket/cmdline + racket/flonum) ;; ------------------------------ ;; define planetary masses, initial positions & velocity diff --git a/collects/tests/racket/benchmarks/shootout/nbody.rkt b/collects/tests/racket/benchmarks/shootout/nbody.rkt index 4f00df5e31..7e94db096c 100644 --- a/collects/tests/racket/benchmarks/shootout/nbody.rkt +++ b/collects/tests/racket/benchmarks/shootout/nbody.rkt @@ -1,4 +1,5 @@ -#!/usr/bin/mzscheme -qu +#lang racket/base + ;; The Computer Language Benchmarks Game ;; http://shootout.alioth.debian.org/ ;; @@ -6,7 +7,7 @@ ;; Patrick Frankenberger and Juho Snellman, but using only native Scheme ;; idioms like 'named let' and 'do' special form. ;; -;; Contributed by Anthony Borla, then converted for mzscheme +;; Contributed by Anthony Borla, then converted for Racket ;; by Matthew Flatt and Brent Fulgham #| @@ -16,9 +17,8 @@ Correct output N = 1000 is -0.169087605 |# -#lang scheme/base -(require scheme/cmdline - scheme/flonum) +(require racket/cmdline + racket/flonum) ;; ------------------------------ ;; define planetary masses, initial positions & velocity diff --git a/collects/tests/racket/benchmarks/shootout/pidigits-gmp.rkt b/collects/tests/racket/benchmarks/shootout/pidigits-gmp.rkt index da65441f08..97f2f854a8 100644 --- a/collects/tests/racket/benchmarks/shootout/pidigits-gmp.rkt +++ b/collects/tests/racket/benchmarks/shootout/pidigits-gmp.rkt @@ -1,12 +1,13 @@ +#lang racket/base + ;; The Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; Based on the Perl version of the benchmark ;; adapted with a GMP interface by Eli Barzilay -#lang scheme/base -(require scheme/cmdline) -(require (for-syntax scheme/base)) -(require scheme/foreign) (unsafe!) +(require racket/cmdline + (for-syntax racket/base) + ffi/unsafe) ;; quick libgmp interface, limited to what we need below (define libgmp (ffi-lib "libgmp")) diff --git a/collects/tests/racket/benchmarks/shootout/pidigits.rkt b/collects/tests/racket/benchmarks/shootout/pidigits.rkt index 3b1e43fc2f..b5912b67ab 100644 --- a/collects/tests/racket/benchmarks/shootout/pidigits.rkt +++ b/collects/tests/racket/benchmarks/shootout/pidigits.rkt @@ -1,10 +1,11 @@ +#lang racket/base + ;; The Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; Based on the MLton version of the benchmark ;; contributed by Scott Cruzen -#lang scheme/base -(require scheme/cmdline) +(require racket/cmdline) (define (floor_ev q r s t x) (quotient (+ (* q x) r) (+ (* s x) t))) diff --git a/collects/tests/racket/benchmarks/shootout/pidigits1.rkt b/collects/tests/racket/benchmarks/shootout/pidigits1.rkt index fce814073b..f93ac3b827 100644 --- a/collects/tests/racket/benchmarks/shootout/pidigits1.rkt +++ b/collects/tests/racket/benchmarks/shootout/pidigits1.rkt @@ -1,4 +1,5 @@ -#!/usr/bin/mzscheme -r +#lang racket/base + ; The Computer Language Shootout ; http://shootout.alioth.debian.org/ ; Sven Hartrumpf 2005-04-12 @@ -6,52 +7,50 @@ ; This program is based on an implementation for SCM by Aubrey Jaffer and ; Jerry D. Hedden. -(module pidigits1 mzscheme - - (define (pi n d) - (let* ((r (inexact->exact (floor (exp (* d (log 10)))))) ; 10^d - (p (+ (quotient n d) 1)) - (m (quotient (* p d 3322) 1000)) - (a (make-vector (+ m 1) 2)) - (out (current-output-port))) - (vector-set! a m 4) - (let j-loop ([b 2][digits 0]) - (if (= digits n) - ;; Add whitespace for ungenerated digits - (let ([left (modulo digits 10)]) - (unless (zero? left) - (fprintf out "~a\t:~a\n" (make-string (- 10 left) #\space) n))) - ;; Compute more digits - (let loop ([k m][q 0]) - (if (zero? k) - (let* ((s (let ([s (number->string (+ b (quotient q r)))]) - (if (zero? digits) - s - (string-append (make-string (- d (string-length s)) #\0) s))))) - (j-loop (remainder q r) - (print-digits out s 0 (string-length s) digits n))) - (let ([q (+ q (* (vector-ref a k) r))]) - (let ((t (+ (* k 2) 1))) - (let-values ([(qt rr) (quotient/remainder q t)]) - (vector-set! a k rr) - (loop (sub1 k) (* k qt))))))))))) +(define (pi n d) + (let* ((r (inexact->exact (floor (exp (* d (log 10)))))) ; 10^d + (p (+ (quotient n d) 1)) + (m (quotient (* p d 3322) 1000)) + (a (make-vector (+ m 1) 2)) + (out (current-output-port))) + (vector-set! a m 4) + (let j-loop ([b 2][digits 0]) + (if (= digits n) + ;; Add whitespace for ungenerated digits + (let ([left (modulo digits 10)]) + (unless (zero? left) + (fprintf out "~a\t:~a\n" (make-string (- 10 left) #\space) n))) + ;; Compute more digits + (let loop ([k m][q 0]) + (if (zero? k) + (let* ((s (let ([s (number->string (+ b (quotient q r)))]) + (if (zero? digits) + s + (string-append (make-string (- d (string-length s)) #\0) s))))) + (j-loop (remainder q r) + (print-digits out s 0 (string-length s) digits n))) + (let ([q (+ q (* (vector-ref a k) r))]) + (let ((t (+ (* k 2) 1))) + (let-values ([(qt rr) (quotient/remainder q t)]) + (vector-set! a k rr) + (loop (sub1 k) (* k qt))))))))))) - (define (print-digits out s start end digits n) - (let* ([len (- end start)] - [cnt (min len (- n digits) (- 10 (modulo digits 10)) len)]) - (if (zero? cnt) - digits - (begin - (write-string s out start (+ start cnt)) - (let ([digits (+ digits cnt)]) - (when (zero? (modulo digits 10)) - (fprintf out "\t:~a\n" digits)) - (print-digits out s (+ start cnt) end digits n)))))) +(define (print-digits out s start end digits n) + (let* ([len (- end start)] + [cnt (min len (- n digits) (- 10 (modulo digits 10)) len)]) + (if (zero? cnt) + digits + (begin + (write-string s out start (+ start cnt)) + (let ([digits (+ digits cnt)]) + (when (zero? (modulo digits 10)) + (fprintf out "\t:~a\n" digits)) + (print-digits out s (+ start cnt) end digits n)))))) - (define (main args) - (let ((n (if (= (vector-length args) 0) - 1 - (string->number (vector-ref args 0))))) - (pi n 10))) - - (main (current-command-line-arguments))) +(define (main args) + (let ((n (if (= (vector-length args) 0) + 1 + (string->number (vector-ref args 0))))) + (pi n 10))) + +(main (current-command-line-arguments)) diff --git a/collects/tests/racket/benchmarks/shootout/regexpdna.rkt b/collects/tests/racket/benchmarks/shootout/regexpdna.rkt index 43700349d1..230ae1376f 100644 --- a/collects/tests/racket/benchmarks/shootout/regexpdna.rkt +++ b/collects/tests/racket/benchmarks/shootout/regexpdna.rkt @@ -1,17 +1,11 @@ -;; --------------------------------------------------------------------- +#lang racket/base + ;; The Great Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; -;; Tested with PCRE [compiler must be built with PCRE already installed -;; else other regex routines (with different behaviours) will be used]. -;; Regex performance appears reasonable, but file loading [of 'large' -;; files] performance requires tweaking to effect a significant improvement. -;; -;; Contributed by Anthony Borla -;; --------------------------------------------------------------------- +;; Based on a version by by Anthony Borla -#lang scheme/base -(require scheme/port) +(require racket/port) ;; ------------------------------- @@ -40,49 +34,22 @@ (match-count str rx (cdar m) (add1 cnt)) cnt))) -;; -------------- - -(define (replace-all rx str new) - (let ([out (open-output-bytes)]) - (let loop ([pos 0]) - (let ([m (regexp-match-positions rx str pos)]) - (if m - (begin - (write-bytes str out pos (caar m)) - (write-bytes new out) - (loop (cdar m))) - (write-bytes str out pos)))) - (get-output-bytes out))) - -;; ------------------------------- - -(define (input->bytes) - (let ([b (open-output-bytes)]) - (copy-port (current-input-port) b) - (get-output-bytes b))) - ;; ------------------------------- ;; Load sequence and record its length -(let* ([orig (input->bytes)] - [filtered (replace-all #rx#"(>.*?\n)|\n" orig #"")]) +(let* ([orig (port->bytes)] + [filtered (regexp-replace* #rx#"(?:>.*?\n)|\n" orig #"")]) ;; Perform regexp counts - (for-each - (lambda (i) - (printf "~a ~a\n" i (match-count filtered (ci-byte-regexp i) 0 0))) - VARIANTS) + (for ([i (in-list VARIANTS)]) + (printf "~a ~a\n" i (match-count filtered (ci-byte-regexp i) 0 0))) ;; Perform regexp replacements, and record sequence length (let ([replaced - (let loop ([sequence filtered] - [IUBS IUBS]) - (if (null? IUBS) - sequence - (loop (replace-all (byte-regexp (caar IUBS)) sequence (cadar IUBS)) - (cdr IUBS))))]) + (for/fold ([sequence filtered]) ([IUB IUBS]) + (regexp-replace* (byte-regexp (car IUB)) sequence (cadr IUB)))]) ;; Print statistics - (printf "~%~A~%~A~%~A~%" + (printf "\n~a\n~a\n~a\n" (bytes-length orig) (bytes-length filtered) (bytes-length replaced)))) diff --git a/collects/tests/racket/benchmarks/shootout/reversecomplement.rkt b/collects/tests/racket/benchmarks/shootout/reversecomplement.rkt index 332250c1f8..fbf1e93117 100644 --- a/collects/tests/racket/benchmarks/shootout/reversecomplement.rkt +++ b/collects/tests/racket/benchmarks/shootout/reversecomplement.rkt @@ -1,32 +1,34 @@ +#lang racket/base + +;; The Computer Language Benchmarks Game +;; http://shootout.alioth.debian.org/ -#lang scheme/base (require scheme/cmdline) (define translation (make-vector 128)) -(for-each (lambda (from-to) - (let ([char (lambda (sym) - (string-ref (symbol->string sym) 0))]) - (let ([from (char (car from-to))] - [to (char->integer (char-upcase (char (cadr from-to))))]) - (vector-set! translation (char->integer from) to) - (vector-set! translation (char->integer (char-upcase from)) to)))) - '([a t] - [c g] - [g c] - [t a] - [u a] - [m k] - [r y] - [w w] - [s s] - [y R] - [k M] - [v b] - [h d] - [d h] - [b v] - [n n])) +(for ([from-to '([a t] + [c g] + [g c] + [t a] + [u a] + [m k] + [r y] + [w w] + [s s] + [y R] + [k M] + [v b] + [h d] + [d h] + [b v] + [n n])]) + (let ([char (lambda (sym) + (string-ref (symbol->string sym) 0))]) + (let ([from (char (car from-to))] + [to (char->integer (char-upcase (char (cadr from-to))))]) + (vector-set! translation (char->integer from) to) + (vector-set! translation (char->integer (char-upcase from)) to)))) (define (output lines) (let* ([str (apply bytes-append lines)] diff --git a/collects/tests/racket/benchmarks/shootout/spectralnorm-generic.rkt b/collects/tests/racket/benchmarks/shootout/spectralnorm-generic.rkt index fd348b0ec7..cac43db8c0 100644 --- a/collects/tests/racket/benchmarks/shootout/spectralnorm-generic.rkt +++ b/collects/tests/racket/benchmarks/shootout/spectralnorm-generic.rkt @@ -1,11 +1,12 @@ +#lang racket/base + ;; The Great Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; Translated directly from the C# version, which was: ;; contributed by Isaac Gouy -#lang scheme/base -(require scheme/cmdline) +(require racket/cmdline) (define (Approximate n) (let ([u (make-vector n 1.0)] diff --git a/collects/tests/racket/benchmarks/shootout/spectralnorm-unsafe.rkt b/collects/tests/racket/benchmarks/shootout/spectralnorm-unsafe.rkt index 5b35f32ca5..8e058f96a2 100644 --- a/collects/tests/racket/benchmarks/shootout/spectralnorm-unsafe.rkt +++ b/collects/tests/racket/benchmarks/shootout/spectralnorm-unsafe.rkt @@ -1,18 +1,19 @@ +#lang racket/base + ;; The Great Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; Translated directly from the C# version, which was: ;; contributed by Isaac Gouy -#lang scheme/base -(require scheme/cmdline - scheme/require (for-syntax scheme/base) +(require racket/cmdline + racket/require (for-syntax racket/base) (rename-in (filtered-in (lambda (name) (regexp-replace #rx"unsafe-" name "")) - scheme/unsafe/ops) + racket/unsafe/ops) [fx->fl ->fl]) - (only-in scheme/flonum make-flvector)) + (only-in racket/flonum make-flvector)) (define (Approximate n) diff --git a/collects/tests/racket/benchmarks/shootout/spectralnorm.rkt b/collects/tests/racket/benchmarks/shootout/spectralnorm.rkt index 7b17629065..fe1a1081cf 100644 --- a/collects/tests/racket/benchmarks/shootout/spectralnorm.rkt +++ b/collects/tests/racket/benchmarks/shootout/spectralnorm.rkt @@ -1,12 +1,13 @@ +#lang racket/base + ;; The Great Computer Language Shootout ;; http://shootout.alioth.debian.org/ ;; Translated directly from the C# version, which was: ;; contributed by Isaac Gouy -#lang scheme/base -(require scheme/cmdline - scheme/flonum) +(require racket/cmdline + racket/flonum) (define (Approximate n) (let ([u (make-flvector n 1.0)] diff --git a/collects/tests/racket/benchmarks/shootout/thread-ring.rkt b/collects/tests/racket/benchmarks/shootout/thread-ring.rkt index 93d05a84b9..c563098ee6 100644 --- a/collects/tests/racket/benchmarks/shootout/thread-ring.rkt +++ b/collects/tests/racket/benchmarks/shootout/thread-ring.rkt @@ -1,7 +1,11 @@ -;; Uses PLT Scheme threads +#lang racket/base -#lang scheme/base -(require scheme/cmdline) +;; The Great Computer Language Shootout +;; http://shootout.alioth.debian.org/ +;; +;; Uses Racket threads + +(require racket/cmdline) ;; Each thread runs this loop: (define (run id next)