3

ファイル project_euler.scm: empty application in source: () の 11 行目で、chibi-scheme v 0.5.3 を使用して以下のコードを実行するたびに ERROR が発生しますが、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)
4

1 に答える 1

8

わかりました、ここで何が起こっているか知っていると思います。chibi-scheme REPL をロードすると、R7RS スキームが使用されますが、ファイルをロードすると、Chibi がサポートする最も基本的なバージョンのスキームが使用されます。参照: http://synthcode.com/scheme/chibi/#h3_SchemeStandard

ファイルの先頭に置く(import (scheme base))と、空のアプリケーションに関するエラーは発生しなくなります。また(import (srfi 1))、使用するリスト処理手順を取得するために行う必要があります。参照: http://synthcode.com/scheme/chibi/#h2_StandardModules

于 2012-07-08T22:27:37.217 に答える