每当我使用 chibi-scheme v 0.5.3 运行下面的代码时,我在文件 project_euler.scm: empty application in source: () 的第 11 行收到一个错误,但是当我使用 Dr Racket 时它运行良好。有谁知道为什么会这样?
#! /usr/bin/env chibi-scheme
(define (sum-of-amicable-pairs n)
(let ((sums (list->vector (map (lambda (i)
(reduce + 0
(filter (lambda (j) (= (remainder i j) 0))
(iota (+ 1 (quotient i 2)) 1 1))))
(iota n 0 1)))))
(let loop ((len (vector-length sums))
(res-list '())
(i 0))
(cond
((= i len) (reduce + 0 res-list))
((and (< (vector-ref sums i) n)
(or (> (vector-ref sums i) i) (< (vector-ref sums i) i))
(= (vector-ref sums (vector-ref sums i)) i))
(loop len (cons (+ (vector-ref sums i) (vector-ref sums (vector-ref sums i))) res-list)
(+ i 1)))
(else
(loop len res-list (+ i 1)))))))
(sum-of-amicable-pairs 10000)