Actions

Programming language shootout: sum file

From Gambit wiki

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This is a Gambit implementation of the sum-file benchmark of the Computer Language Benchmarks Game.

I have no idea what the real data is supposed to be.

The program

#!gsi-script

;; The Computer Language Benchmarks Game
;; http://shootout.alioth.debian.org/
;;
;; Derived by Bradley Lucier from the Ikarus variant
;; derived by Michael D. Adams from the MzScheme variant

(declare (standard-bindings)(extended-bindings)(block)(not safe))


(define (main)
  (time (let ([in (current-input-port)])
    (let loop ([acc 0])
      (let ([n (read-line in)])
	(if (eof-object? n)
	    (begin (display acc) (newline))
	    (loop (+ acc (string->number n)))))))))

Compiling

gsc sum-file

Running

gsi sum-file < sum-file.in