#!/usr/local/bin/guile \ -e main -s !# ;;; $Id: sieve.guile,v 1.8 2001/06/29 23:12:37 doug Exp $ ;;; http://www.bagley.org/~doug/shootout/ ;;; with help from Benedikt Rosenau (use-modules (ice-9 format)) (define (main args) (let ((n (or (and (= (length args) 2) (string->number (cadr args))) 1)) (count 0)) (while (> n 0) (set! n (- n 1)) (let ((flags (make-vector 8192 #t))) (set! count 0) (do ((i 2 (+ 1 i))) ((>= i 8192)) (if (vector-ref flags i) (begin (do ((k (+ i i) (+ k i))) ((>= k 8192)) (vector-set! flags k #f)) (set! count (+ 1 count))))))) (display (format "Count: ~D\n" count))))